careym1989 Posted November 14, 2008 Share Posted November 14, 2008 hey all, I'm having trouble with the script that I've written here. This is a script that is for RSVPs to various events (it's supposed to be very dynamic with the $_GET feature included). Problem explained after code. Seems to be a basic problem but I just can't get it. here's rsvp.php (the form): <!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=utf-8" /> <title>RSVP to an Event</title> </head> <body> <p> <?php $eventTitle = $_GET["eventTitle"]; $eventTime = $_GET["eventTime"]; $eventDate = $_GET["eventDate"]; ?> RSVP to an Event! <br /> <br /> <br /> </p> <form id="rsvp" name="rsvp" method="post" action="rsvp2.php"> <?php echo stripslashes($eventTitle); echo "<br><br>$eventTime on $eventDate<br><br>"; ?> <input type="hidden" name"eventTitle" id="eventTitle" value="<?php $eventTitle ?>" /> <input type="hidden" name"eventTime" id="eventTime" value="<?php $eventTime ?>" /> <input type="hidden" name"eventDate" id="eventDate" value="<?php $eventDate ?>" /> <p> <label>Your Name <input type="text" name="attendeeName" id="attendeeName" /> </label> </p> <p> <label>Your Email Address <input type="text" name="attendeeEmail" id="attendeeEmail" /> </label> </p> <p> <label>Your Phone Number <input type="text" name="attendeePhone" id="attendeePhone" /> </label> </p> <p> <input type="hidden" name="rsvp" id="1" value="1"/></p> <p> <input type="submit" name="submit" id="submit" value="RSVP" /> </p> </form> <p> </p> <br /><br /> </body> </html> and here's rsvp2.php, the part that inserts into database and confirms: <!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=utf-8" /> <title>Thank you for your RSVP!</title> </head> <body> <?php $rsvp = $_REQUEST['rsvp']; if ($rsvp==1) { $attendeeName = $_REQUEST['attendeeName']; $eventTime = $_REQUEST['eventTime']; $eventDate = $_REQUEST['eventDate']; $db = mysql_connect("xxx","xxx","xxx") or die("Cannot connect to server"); mysql_select_db("xxx",$db) or die("Cannot find database"); $sql = mysql_query("INSERT INTO event_rsvp (eventTitle, eventTime, eventDate, attendeeName, attendeeEmail, attendeePhone) VALUES('$eventTitle', '$eventTime', '$eventDate', '$attendeeName', '$attendeeEmail', '$attendeePhone')") or die (mysql_error()); echo "Thank you for your RSVP, $attendeeName."; echo "<br><br><br>"; echo "Remember this date and time:<br><br>"; echo $eventTime; echo " on "; echo $eventDate; } else { echo "Sorry, please go back and try again."; } ?> </body> </html> for some reason, when I check the table in the database, I only get the attendee field information. I don't get the eventTitle, eventTime, and eventDate in the table -- it's just blank. Furthermore, on the confirmation page, only the attendee's name shows up in the echo section. eventDate and eventTime don't appear it looks just like " on ". There has got to be a simple solution to this. Help would be much appreciated. Regards, Carey Link to comment https://forums.phpfreaks.com/topic/132660-solved-form-to-insert-into-database-trouble/ Share on other sites More sharing options...
zenag Posted November 14, 2008 Share Posted November 14, 2008 '=' & echo seems missing... <input type="hidden" name="eventTitle" id="eventTitle" value="<?php echo $eventTitle ?>" /> <input type="hidden" name="eventTime" id="eventTime" value="<?php echo $eventTime ?>" /> <input type="hidden" name="eventDate" id="eventDate" value="<?php echo $eventDate ?>" /> Link to comment https://forums.phpfreaks.com/topic/132660-solved-form-to-insert-into-database-trouble/#findComment-689938 Share on other sites More sharing options...
careym1989 Posted November 14, 2008 Author Share Posted November 14, 2008 That would totally be it. I tried it with echo first, then took it out to see if it would work and forgot to put it back in. The ='s are totally the problem though. It's been a long day. Thank you very much. Link to comment https://forums.phpfreaks.com/topic/132660-solved-form-to-insert-into-database-trouble/#findComment-689942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.