logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-01-2007, 03:50 PM   #1
Predator
 
Join Date: Apr 2007
Posts: 15
Default data not submitting to database.

hi i am on the php beginners tutorial and i am on part 9. I have watched the video tutorial and done everything it says. I am learning so much and i thank you for that. I am 15 atm and im not clever you guys at this forums so any help would be much appreciated.

Here is my code atm.
PHP Code:
<?php
require_once("Connections/connection.php"); // database connection

////////////////////////////////////////////////
$data2    =    $_POST['data2'];
$data3    =    $_POST['data3'];
$data4    =    $_POST['data4'];
$submit    =    $_POST['submit'];
////////////////////////////////////////////////

if ($sumbit && $data2 && data3 && data4) {

/////////////////////////////////////////////
$query    =    sprintf("INSERT into table1 (field2, field3, field4) values ('$data2', '$data3', '$data4')");
            
mysql_query($query) or die (mysql_error());
/////////////////////////////////////////////

}elseif($submit){

echo 
"One of your fields is empty!";

}

///////////////////////////////////////////////
$query    =    sprintf("SELECT * FROM table1");
$result    =    @mysql_query($query);
$row    =    mysql_fetch_array($result); // contains all the database data
///////////////////////////////////////////////

/*do{
echo $row['field3']."<br>"; // target certain data

}while ($row = mysql_fetch_array($result))*/

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <table width="200" border="1" cellspacing="0" cellpadding="0">
    <tr>
      <td>data2</td>
      <td>data3</td>
      <td>data4</td>
    </tr>
    <tr>
      <td><input name="data2" type="text" id="data2" /></td>
      <td><input name="data3" type="text" id="data3" /></td>
      <td><input name="data4" type="text" id="data4" /></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">
        <input type="submit" name="Submit" value="Submit" />
        <input name="submit" type="hidden" id="submit" value="1" />
      </div></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<table width="429" height="68" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td>ID</td>
    <td>data2</td>
    <td>data3</td>
    <td>data4</td>
  </tr>
  <?php do{ ?>
  <tr>
    <td><?php echo $row['field1_id']; ?></td>
    <td><?php echo $row['field2']; ?></td>
    <td><?php echo $row['field3']; ?></td>
    <td><?php echo $row['field4']; ?></td>
  </tr>
  <?php }while ($row mysql_fetch_array($result)); ?>
</table>
</body>
</html>
That is my code, and my problem is when i run it and enter details and i press sumbit, it come up with the message "One of your fields is empty!" but i have entered all the fields. I would like to know what i am doing wrong.
Thank you, any help would be much appreciated.
Predator is offline   Reply With Quote
Old 04-01-2007, 04:45 PM   #2
Predator
 
Join Date: Apr 2007
Posts: 15
Default

o found out what was wrong i spelled submit wrong. sorry my fault.
Predator is offline   Reply With Quote
Old 04-01-2007, 04:55 PM   #3
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

in this line
PHP Code:
 
if ($sumbit && $data2 && data3 && data4) { 
you have sumbit not submit


always check your spelling!
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:54 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com