clankill3r Posted September 9, 2011 Share Posted September 9, 2011 I have a quite old book about database applications, and i got a problem with it. I have this page, create_entry.php <?php include("dbconnect.php"); if ($submit == "Sign") { $query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')"; mysql_query($query) or die (mysql_error()); ?> <h2>Thanks!!</h2> <h2><a href="view.php">View my guestbook!</a></h2> <?php } else { include("sign.php"); } ?> and i got this page named sign.php <h2>Sign my guestbook</h2> <form method="post" action="create_entry.php"> <b>Name:</b> <input type="text" size="40" name="name"> </br> <b>Location:</b> <input type="text" size="40" name="location"> </br> <b>Email:</b> <input type="text" size="40" name="email"> </br> <b>Home Page Url:</b> <input type="text" size="40" name="url"> </br> <b>Comments:</b> <textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea> </br> <input type="submit" name="submit" value="Sign"> <input type="reset" name="reset" value="Start Over"> </form> When i open create_entry.php then sign.php is indeed shown up. However when i send, it brings me to the same page with no Thanks!! etc. Also nothing gets inserted in the database. Hope i explained well enough Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/ Share on other sites More sharing options...
Muddy_Funster Posted September 9, 2011 Share Posted September 9, 2011 You have completly missed out the part where you assign your variables from $_POST[] is that the complete code you are working with? Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/#findComment-1267292 Share on other sites More sharing options...
Pikachu2000 Posted September 10, 2011 Share Posted September 10, 2011 Throw that book in the bin. It relies on register_globals. Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/#findComment-1267575 Share on other sites More sharing options...
clankill3r Posted September 10, 2011 Author Share Posted September 10, 2011 that is the complete code, exept there is a file dbconnect.php but that one is very straight forward. register_globals, what does that mean? but i think your right, time for another book. Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/#findComment-1267609 Share on other sites More sharing options...
redarrow Posted September 10, 2011 Share Posted September 10, 2011 you need to add all your name references to post the variables <?php if($_POST['submit']){ $name=$_POST['name']; $location=$_POST['location']; // do what ever with the posted variables. } ?> Also i agree, your book out dated, wrong php book version,your studying php 3/4 but using php 5/nearly 6. Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/#findComment-1267610 Share on other sites More sharing options...
redarrow Posted September 10, 2011 Share Posted September 10, 2011 Try this for a example might work. Warning all the information needs validating........ <?php include("dbconnect.php"); if ($_POST['submit'] == "Sign") { $name=$_POST['name']; $location=$_POST['location']; $email=$_POST['email']; $url=$_POST['url']; $comments=$_POST['comments']; $query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')"; mysql_query($query) or die (mysql_error()); ?> <h2>Thanks!!</h2> <h2><a href="view.php">View my guestbook!</a></h2> <?php } else { include("sign.php"); } ?> <h2>Sign my guestbook</h2> <form method="post" action="create_entry.php"> <b>Name:</b> <input type="text" size="40" name="name"> </br> <b>Location:</b> <input type="text" size="40" name="location"> </br> <b>Email:</b> <input type="text" size="40" name="email"> </br> <b>Home Page Url:</b> <input type="text" size="40" name="url"> </br> <b>Comments:</b> <textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea> </br> <input type="submit" name="submit" value="Sign"> <input type="reset" name="reset" value="Start Over"> </form> Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/#findComment-1267613 Share on other sites More sharing options...
clankill3r Posted September 10, 2011 Author Share Posted September 10, 2011 thanks for your help but i prefer another book, if a book starts like this then it can't be good anymore. Link to comment https://forums.phpfreaks.com/topic/246775-it-doesnt-work-but-neither-a-error/#findComment-1267615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.