PDA

View Full Version : Davidj Part9 complications


TheNewTag
09-17-2008, 12:15 AM
I am trying to get my submit form working, and for the life of me, I cannot find where I am missing anything!
Please, anyone have any suggestions?


<?php
require_once("Connections/connection.php"); //database connection
//////////////////////////////////////
$data2 = $_POST['data2'];
$data3 = $_POST['data3'];
$data4 = $_POST['data4'];
$submit = $_POST['submit'];
////////////////////////////////////////
if ($submit && $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 "still not there!";
}
/////////////////////////////////////////////////////
$query =sprintf("SELECT * FROM table1");
$result =@mysql_query($query);
$row =mysql_fetch_array($result);
/////////////////////////////////////////////////////


When I insert the text and hit submit, it does display my "echo" response, so, being a beginner, I know that from that point down in the script works ok.
I also know that the "require_once" section works, otherwise I would have no form showing up in the first place. So, what am I doing wrong?

TheNewTag. Daniel.

edbr
09-17-2008, 02:05 AM
are these the actual names of your fields
table1 (field2, field3, field4

TheNewTag
09-17-2008, 10:44 PM
Yes, those are my field names. I did it just like the tutorial shows, therefore, beside the name of the document (practice.php instead of dwc.php), everything should be identical.

TheNewTag
09-17-2008, 11:19 PM
I also just now went ahead and did the next tutorial (Part10) and everthing has been typed the same. When I went to look at the 'source code' for the page like david shows in his tutorial, I get a blank page. This could be a symptom of my problem. I don't know; just thought it might help.

davidj
09-18-2008, 07:04 AM
($submit && $data2 && $data3 && $data4){


if these are set then your code should run. If you are echoing your warning then one of the above is not being set. You need to echo each variables
to see whats in them.

TheNewTag
09-18-2008, 11:09 PM
The solution was found when I noticed that I forgot the '=' in the coding that was placed in the html portion. I didn't place the "onClick" equal sign, and when I selected the text and copied it again to update, the mistake was carried over. I couldn't update or delete, and now I can.

<tr>
<td>
<input type="button" name="button2" value="Update" onClick="document.location.href='practice.php?upd=<?php echo $row['field1_id']?>'"/>
</td>
<td height="27"><?php echo $row['field1_id'];?></td>

I am now doing the login tutorials. Everything works great. BTW, David, your tutorials are AWESOME! I was able to understand everything as I went.

I am stuck on the last part. The Logoff works, but when I try to do the security portion, it tells me that "includes/security.php" isn't there. And yes, I did double and triple check. Everything is spelled correctly.

At first, all it did was keep going back to the login page, as if I was trying to enter the welcom.php without permission. Then I tried typing in the whole path

("C:/wamp/www/WebRoot/Test/includes/security.php")

This took me to the welcome page, but told me that the file wasn't there...

???Help???

davidj
09-19-2008, 06:42 AM
post your code