ChompGator Posted November 28, 2007 Share Posted November 28, 2007 Hello, Im having a problem with a subscription script I made. Its a basic script, and the purpose of it is to allow a user to enter their email address, forename, surname, and select weather they are a business user or home user, then click "submit" and the information gets entered into the database/table I made for the script. Now the problem Im having is the script works, and it submits, the problem is if I go look in the database the script didn't actually insert any information into the database. Below I have included the html form, and the handle.php (the php script that handles the form information) I was hoping someone may be able to provide some insight/advice as to why its not inserting whats in the field values into the database. - Thanks HTML Script: <html> <body> FORM id=mailinglist name=mailinglist onsubmit="return emailOnly(this.emaillist.value,'emaillist');" action="handle.php" method=post <INPUT type=hidden value="Interactive Systems" name=thispage> <INPUT type=hidden value=Main name=thissection> <a title="AIIM Calgary Home Page" target="_self" href="http://www.aiimcalgary.org">Home</a> | <a href="http://calendar.aiimcalgary.org">Calendar</a> | Join The Calgary Chapter Mailing List: <INPUT class=small id=emaillist onkeydown="hideshow('mldetails','on');" onblur="return handleEmp(this,'Your Email');" onfocus="clearThis(this,'Your Email');hideshow('mldetails','on');" align=top size=24 value="Your email" name=emaillist> <INPUT class=submit id=join type=submit align=top value=Join name=join> <DIV class=off id=mldetails onmouseover="hideshow('mldetails','on');" onmouseout="hideshow('mldetails','off');"> <FIELDSET><LEGEND>Optional Details:</LEGEND><LABEL for=mlfname>Forename:</LABEL><INPUT class=small id=mlfname maxLength=50 name=mlfname><BR><LABEL for=mllname>Surname:</LABEL><INPUT class=small id=mllname maxLength=50 name=mllname><BR>[<A title="View AIIM' Privacy Policy: How we handle your personal information" href="javascript:openWin('/legal/privacy_policy.asp','privacy','795','550')">Privacy</A>] <SELECT class=small size=1 name=mltype> <OPTION value=business selected>I'm a Business User</OPTION> <OPTION value=home>I'm a Home User</OPTION><OPTION value=home>I'm a New User</OPTION></SELECT> </FIELDSET> </DIV></FORM> <SCRIPT type=text/javascript> //hide mailing list options on load hideshow('mldetails','off'); </SCRIPT> </body> </html PHP Script: <?php $con = mysql_connect("mysql105.mysite4now.com","aiim","k7YuHeFv"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("login", $con);$sql="INSERT INTO subscribe (email, forename, surname, user) VALUES ('$_POST','$_POST[forename]','$_POST[surname]','user')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added";mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 28, 2007 Share Posted November 28, 2007 Are you getting any errors, or is it telling you the record was added? Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 28, 2007 Share Posted November 28, 2007 I'm going to teach you the OR clause when using functions <?php $con = mysql_connect("mysql105.mysite4now.com","aiim","k7YuHeFv") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $sql="INSERT INTO subscribe (email, forename, surname, user) VALUES ('$_POST[email]','$_POST[forename]','$_POST[surname]','user')"; $query = mysql_query($sql,$con) or die('Error: ' . mysql_error()); if ($query) { echo "1 record added";mysql_close($con); } else { echo "Not added.."; } ?> try that code ^ Also, is anything being sent to the $_POST vars? what error are you getting? Quote Link to comment Share on other sites More sharing options...
ChompGator Posted November 28, 2007 Author Share Posted November 28, 2007 It is saying "1 Record Added" But nothing was added Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 28, 2007 Share Posted November 28, 2007 ^ Did you use the code I posted above? also, clean up your html.. is is so messy, ive never seen it so bad.. also, put <> tags around your FORM: <FORM id=mailinglist name=mailinglist onsubmit="return emailOnly(this.emaillist.value,'emaillist');" action="handle.php" method=post> Quote Link to comment Share on other sites More sharing options...
ChompGator Posted November 28, 2007 Author Share Posted November 28, 2007 Hmm, let me try it give me a second here Quote Link to comment Share on other sites More sharing options...
ChompGator Posted November 28, 2007 Author Share Posted November 28, 2007 Nope, same thing, it says "1 Record AddeD" But the form information was not added to the table in the db. Quote Link to comment Share on other sites More sharing options...
ChompGator Posted November 28, 2007 Author Share Posted November 28, 2007 I used the code you posted above, and the same thing is still happening, its saying 1 Record Added, but its not actually adding any of the information from the form into the database. Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 28, 2007 Share Posted November 28, 2007 Fix this line.. I didn't see it before.. change it to this: $sql="INSERT INTO subscribe (email, forename, surname, user) VALUES ('".$_POST['email']."','".$_POST['forename']."','".$_POST['surname']."','user')"; Quote Link to comment Share on other sites More sharing options...
ChompGator Posted November 28, 2007 Author Share Posted November 28, 2007 Still Nothing :-X Quote Link to comment 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.