Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Help with the php/mysql stuff, please.

Codes here !

Moderators: macek, egami, gesf

Postby webwired » Wed Dec 11, 2002 11:16 am

I don't know what's up with your code, but it's nearly impossible to look at... but here, I've included an insert form for you to look at
Code: Select all
<html>
<body>
<center>

<?php
if(!$submit)
{
?>

<form action="<?php $PHP_SELF ?>" method="post">
<table width="500" bordercolor="#000000" cellspacing="0" cellpadding="2" border="1">
  <tr>
    <td>&nbsp;Field1</td>
    <td>
<input type="text" name="field1" size="35">
    </td>
  </tr>
  <tr>
    <td>&nbsp;Field2</td>
    <td>
<input type="text" name="field2" size="35">
    </td>
  </tr>
  <tr>
    <td>&nbsp;Field3</td>
    <td>
<input type="text" name="field3" size="35">
    </td>
  </tr>
  <tr>
    <td>&nbsp;Field4</td>
    <td>
<input type="text" name="field4" size="35">
    </td>
  </tr>
  <tr>
    <td colspan=2>
<center>
<input type="submit" name="submit" value="Add">
</center>
    </td>
  </tr>
</table>
</form>

<?php
}else{
?>

<form action="<?php $PHP_SELF ?>" method="post">
<table width="500" bordercolor="#000000" cellspacing="0" cellpadding="2" border="1">
  <tr>
    <td>&nbsp;Field1</td>
    <td>
<input type="text" name="field1" size="35">
    </td>
  </tr>
  <tr>
    <td>&nbsp;Field2</td>
    <td>
<input type="text" name="field2" size="35">
    </td>
  </tr>
  <tr>
    <td>&nbsp;Field3</td>
    <td>
<input type="text" name="field3" size="35">
    </td>
  </tr>
  <tr>
    <td>&nbsp;Field4</td>
    <td>
<input type="text" name="field4" size="35">
    </td>
  </tr>
  <tr>
    <td colspan=2>
<center>
<input type="submit" name="submit" value="Add">
</center>
    </td>
  </tr>
</table>
</form>

<?php
include_once "../../cgi-bin/includes/ez_sql.php";
$sqlquery = "INSERT INTO yourtable VALUES ('$field1','$field2','$field3','$field4')";
$results = mysql_query($sqlquery);
mysql_close();
?>

<?php
}
?>

</center>
</body>
</html>
User avatar
webwired
New php-forum User
New php-forum User
 
Posts: 26
Joined: Sat Nov 23, 2002 5:20 pm
Location: St. Louis, Missouri

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.