m2e Posted February 4, 2009 Share Posted February 4, 2009 Hello, hope someone can help me out - I have a feeling its somthing silly, but I've been staring at it so long I dont know now! I have a guest list signup form which I have been using for a while. I have moved the code over from another website where it was working - however now it doesnt seem to be working. There are three files:- index.html This contains the form - which uses the post method and sends details to bookings.php bookings.php Does the work of adding the signup to the database and sending an email for the user to confirm their sign-up once they receive this email and click on the link this envokes booking-confirmed.php booking-confirmed.php Sends the user back to the orginal website and prints a message saying that their registration has been successful. The form submits, and an email is sent - but nothing is being written to the database - and the email variable does not seem to be passed to the next page. The form can be seen here http://www.bigsixmedia.net/eventsignup If you click on the link and then fill in the details on the form, and hit submit, the details are sent to the database, with a confirmed marker of 'N' for no. The user is also sent an email (to the address you specified) with a link inside it asking you to click it - this then takes you back to the website and to a confirmation page, the marker in the database is now set to 'Y' for yes. I have also pasted below the php part of booking.php: <?php #ensure all fields have entries if ($fullname and $email and $mobile) { #connect to mysql $conn=@mysql_connect("localhost", "gbsnadmin", "goldcoast1") or die ("Err:Conn"); #select the specified database $rs = @mysql_select_db("gbsn", $conn) or die ("Err:Conn"); #create the 1st query $date="AYEKOO_AP_070309"; $sql="SELECT * FROM event_signups WHERE email = \"".$email."\" AND date = \"".$date."\""; #execute 1st query $rs=mysql_query($sql,$conn); #add entry if NO matching record was found, else deny sign-up if (mysql_num_rows($rs)) { echo "The email address, $email has already been signed up for this event!"; exit; } else { #create the 2nd query $sql="INSERT INTO event_signups(date, fullname, email, mobile) VALUES ( \"$date\", \"$fullname\", \"$email\", \"$mobile\")"; #execute the query $rs=mysql_query($sql,$conn); } #confirm the added record details if($rs) {echo ("Thank you $fullname - We have received your request for guestlist.\n\nTo confirm this an email will be sent to $email - \n\nYOU MUST CLICK ON THE CONFIRMATION LINK - \n\nFailure to do this will result in your name not being submitted"); } } #***************************************************************** #*********************** Send Email Script *********************** #***************************************************************** #this is the recipients email address $to = "rgevans@gmail.com, $email"; #this is the subject of the message $re = "PLEASE CONFIRM YOUR EVENT SIGN-UP"; #build the URL - this is the message with the link to the url $msg = "PLEASE CLICK THE LINK BELOW TO CONFIRM YOUR SIGN-UP\n\nYOU WILL BE SENT A CONFIRMATION EMAIL SHORTLY AFTER THIS\n\nhttp://www.thegbsn.com/eventsignup/booking-confirmed.php?email=$email\n\nIf you can not click on this link copy and paste ALL of the link into your browser"; #this is where the from header is set $headers .= "From: signup@thegbsn.com \r\n"; #this part sends the email mail($to,$re,$msg, $headers); ?> Thanks for your help!!! Quote Link to comment https://forums.phpfreaks.com/topic/143769-php-writing-to-database-issue/ Share on other sites More sharing options...
Maq Posted February 4, 2009 Share Posted February 4, 2009 $sql="SELECT * FROM event_signups WHERE email = \"".$email."\" AND date = \"".$date."\""; Make life easier and use single quotes around your values (for both queries): $sql="SELECT * FROM event_signups WHERE email = '$email' AND date = '$date'"; You should also echo the sql statements to see what's actually being passed through. Add or die(mysql_error()) for each mysql_query function: $rs=mysql_query($sql,$conn) or die(mysql_error()); You should either get errors or see the wrong query echoed to your browser. Quote Link to comment https://forums.phpfreaks.com/topic/143769-php-writing-to-database-issue/#findComment-754303 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.