Dominee Posted July 18, 2011 Share Posted July 18, 2011 Hi people, I made a join form, but I got a problem. When I fill in my information and I press "Submit" I get a error: You did not submit the following required information! --- Email Address You can see this error in the picture I uploaded. Here is my code <?php // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['username'])){ //Connect to the database through our include include_once "connect_to_mysql.php"; // Filter the posted variables $username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters $country = ereg_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters $state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters $city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters $accounttype = ereg_replace("[^a-z]", "", $_POST['accounttype']); // filter everything but lowercase letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters // Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if((!$username) || (!$country) || (!$state) || (!$city) || (!$accounttype) || (!$email) || (!$password)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$username){ $errorMsg .= "--- User Name"; } else if(!$country){ $errorMsg .= "--- Country"; } else if(!$state){ $errorMsg .= "--- State"; } else if(!$city){ $errorMsg .= "--- City"; } else if(!$accounttype){ $errorMsg .= "--- Account Type"; } else if(!$email){ $errorMsg .= "--- Email Address"; } else if(!$password){ $errorMsg .= "--- Password"; } } else { // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1"); $sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); $email_check = mysql_num_rows($sql_email_check); if ($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another."; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another."; } else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = mysql_query("INSERT INTO members (username, country, state, city, accounttype, email, password, signupdate) VALUES('$username','$country','$state','$city','$accounttype','$email','$hashedPass', now())") or die (mysql_error()); // Get the inserted ID here to use in the activation email $id = mysql_insert_id(); // Create directory(folder) to hold each user files(pics, MP3s, etc.) mkdir("memberFiles/$id", 0755); // Start assembly of Email Member the activation link $to = "$email"; // Change this to your site admin email $from = "[email protected]"; $subject = "De laatste stap!"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $username . ', <br /><br /> You must complete this step to activate your account with us. <br /><br /> Please click here to activate now >> <a href="http://www.poetsproduct.com/activation.php?id=' . $id . '"> ACTIVATE NOW</a> <br /><br /> Your Login Data is as follows: <br /><br /> E-mail Address: ' . $email . ' <br /> Password: ' . $password . ' <br /><br /> Thanks! </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; exit(); // Exit so the form and page does not display, just this success message } // Close else after database duplicate field value checks } // Close else after missing vars check } //Close if $_POST ?> <?php session_start(); // Must start session first thing $toplinks = ""; if (isset($_SESSION['id'])) { // Put stored session variables into local php variable $userid = $_SESSION['id']; $username = $_SESSION['username']; $toplinks = '<a href="member_profile.php?id=' . $userid . '">Welkom ' . $username . '</a> • <a href="cart.php">Winkelwagen</a> • <a href="logout.php">Log uit</a>'; } else { $toplinks = '<a href="join_form.php">Registreren</a> • <a href="login.php">Login</a>'; } ?> <html> <head> <title>PoetsProduct | Webshop</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <style type="text/css"> <!-- #Table_01 tr td p { font-family: Arial, Helvetica, sans-serif; } #Table_01 tr td p a { font-size: 12px; } #Table_01 tr td p a { font-size: 10px; } body { background-image: url(images/Stroke.png); background-repeat: repeat-x; } --> </style> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('Rollover/images/New-15-07_28.png','Rollover/images/New-15-07_30-31.png','Rollover/images/New-15-07_31.png','Rollover/images/New-15-07_32.png','Rollover/images/New-15-07_34-35.png','Rollover/images/New-15-07_35.png','Rollover/images/New-15-07_12.png','Rollover/images/New-15-07_14.png','Rollover/images/New-15-07_16.png')"> <table align="center" id="Table_01" width="1201" height="951" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="18"> <img src="images/New-15-07_01.png" width="1200" height="11" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="11" alt=""></td> </tr> <tr> <td colspan="2" rowspan="15"> <img src="images/New-15-07_02.png" width="57" height="355" alt=""></td> <td colspan="4" rowspan="5"> <img src="images/New-15-07_03.png" width="271" height="70" alt=""></td> <td colspan="12"> <img src="images/New-15-07_04.png" width="872" height="21" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="21" alt=""></td> </tr> <tr> <td colspan="7" rowspan="2"> <img src="images/New-15-07_05.png" width="89" height="21" alt=""></td> <td width="307" height="49" rowspan="4" align="left" valign="middle" background="images/New-15-07_06.png" alt=""><?php echo $toplinks; ?> </td> <td colspan="4"> <img src="images/New-15-07_07.png" width="476" height="8" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="8" alt=""></td> </tr> <tr> <td rowspan="4"> <img src="images/New-15-07_08.png" width="135" height="69" alt=""></td> <td background="images/New-15-07_08-10.png" width="227" height="33" alt="" rowspan="2"><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=229946050359156&xfbml=1"></script><fb:like href="http://www.facebook.com/pages/PoetsProduct/236503569702627" send="true" layout="button_count" width="75" show_faces="false" font="arial"></fb:like> </td> <td colspan="2" rowspan="4"> <img src="images/New-15-07_10.png" width="114" height="69" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="13" alt=""></td> </tr> <tr> <td rowspan="3"> <img src="images/New-15-07_11.png" width="2" height="56" alt=""></td> <td> <a href="http://www.facebook.com/pages/PoetsProduct/236503569702627"> <img src="images/New-15-07_12.png" alt="" width="20" height="20" border="0" id="Image7" onMouseOver="MM_swapImage('Image7','','Rollover/images/New-15-07_12.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td rowspan="3"> <img src="images/New-15-07_13.png" width="3" height="56" alt=""></td> <td> <a href="https://twitter.com/#!/PoetsProduct"> <img src="images/New-15-07_14.png" alt="" width="20" height="20" border="0" id="Image8" onMouseOver="MM_swapImage('Image8','','Rollover/images/New-15-07_14.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td rowspan="3"> <img src="images/New-15-07_15.png" width="3" height="56" alt=""></td> <td> <a href="http://hyves.nl/?pageid=AAXGFZMH1OG0O0C4K "> <img src="images/New-15-07_16.png" alt="" width="20" height="20" border="0" id="Image9" onMouseOver="MM_swapImage('Image9','','Rollover/images/New-15-07_16.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td rowspan="3"> <img src="images/New-15-07_17.png" width="21" height="56" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="20" alt=""></td> </tr> <tr> <td rowspan="2"> <img src="images/New-15-07_18.png" width="20" height="36" alt=""></td> <td rowspan="2"> <img src="images/New-15-07_19.png" width="20" height="36" alt=""></td> <td rowspan="2"> <img src="images/New-15-07_20.png" width="20" height="36" alt=""></td> <td rowspan="2"> <img src="images/New-15-07_21.png" width="227" height="36" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="8" alt=""></td> </tr> <tr> <td colspan="4"> <img src="images/New-15-07_22.png" width="271" height="28" alt=""></td> <td> <img src="images/New-15-07_23.png" width="307" height="28" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="28" alt=""></td> </tr> <tr> <td rowspan="2"> <img src="images/New-15-07_24.png" width="1" height="82" alt=""></td> <td background="images/New-15-07_25.png" width="1038" height="62" alt="" colspan="14"><img src="images/Banner.png" width="1037" height="62" alt="Banner"></td> <td rowspan="15"> <img src="images/New-15-07_26.png" width="104" height="841" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="62" alt=""></td> </tr> <tr> <td colspan="14"> <img src="images/New-15-07_27.png" width="1038" height="20" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="20" alt=""></td> </tr> <tr> <td colspan="2"> <a href="http://www.Poetsproduct.nl/index.php"> <img src="images/New-15-07_28.png" alt="" width="157" height="28" border="0" id="Image1" onMouseOver="MM_swapImage('Image1','','Rollover/images/New-15-07_28.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td rowspan="13"> <img src="images/New-15-07_29.png" width="10" height="759" alt=""></td> <td width="872" height="759" colspan="12" rowspan="13" align="left" valign="top" background="images/New-15-07_30.png" alt=""><img src="images/Blanko.png" width="270" height="61" alt="Blank"> <img src="images/Logo-PP-Registreren.png" width="300" height="90" alt="Registreren"><br><table width="600" align="center" cellpadding="5"> <form action="join_form.php" method="post" enctype="multipart/form-data"> <tr> <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> </tr> <tr> <td width="163"><div align="right">User Name:</div></td> <td width="409"><input name="username" type="text" value="<?php echo "$username"; ?>" /></td> </tr> <tr> <td><div align="right">Country:</div></td> <td><select name="country"> <option value="<?php echo "$country"; ?>"><?php echo "$country"; ?></option> <option value="Nederland">Nederland</option> </select></td> </tr> <tr> <td><div align="right">State: </div></td> <td><input name="state" type="text" value="<?php echo "$state"; ?>" /></td> </tr> <tr> <td><div align="right">City: </div></td> <td> <input name="city" type="text" value="<?php echo "$city"; ?>" /> </td> </tr> <tr> <td><div align="right">Account Type: </div></td> <td><select name="accounttype"> <option value="<?php echo "$accounttype"; ?>"><?php echo "$accounttype"; ?></option> <option value="a">Normal User</option> <option value="b">Expert User</option> <option value="c">Super User</option> </select></td> </tr> <tr> <td><div align="right">Email: </div></td> <td><input name="email" type="text" value="<?php echo "$email"; ?>" /></td> </tr> <tr> <td><div align="right"> Password: </div></td> <td><input name="password" type="password" value="<?php echo "$password"; ?>" /> <font size="-2" color="#006600">(letters or numbers only, no spaces no symbols)</font></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table></td> <td> <img src="images/spacer.gif" width="1" height="28" alt=""></td> </tr> <tr> <td colspan="2"> <a href="http://www.Poetsproduct.nl/Assortiment.php"> <img src="images/New-15-07_30-32.png" alt="" width="157" height="29" border="0" id="Image2" onMouseOver="MM_swapImage('Image2','','Rollover/images/New-15-07_30-31.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td> <img src="images/spacer.gif" width="1" height="29" alt=""></td> </tr> <tr> <td colspan="2"> <a href="http://www.Poetsproduct.nl/Over_ons.php"> <img src="images/New-15-07_31.png" alt="" width="157" height="27" border="0" id="Image3" onMouseOver="MM_swapImage('Image3','','Rollover/images/New-15-07_31.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td> <img src="images/spacer.gif" width="1" height="27" alt=""></td> </tr> <tr> <td colspan="2"> <a href="http://www.Poetsproduct.nl/Verzenden.php"> <img src="images/New-15-07_32.png" alt="" width="157" height="28" border="0" id="Image4" onMouseOver="MM_swapImage('Image4','','Rollover/images/New-15-07_32.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td> <img src="images/spacer.gif" width="1" height="28" alt=""></td> </tr> <tr> <td rowspan="3"> <img src="images/New-15-07_34.png" width="1" height="63" alt=""></td> <td> <a href="http://www.Poetsproduct.nl/Betalen.php"> <img src="images/New-15-07_34-36.png" alt="" width="156" height="26" border="0" id="Image5" onMouseOver="MM_swapImage('Image5','','Rollover/images/New-15-07_34-35.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td> <img src="images/spacer.gif" width="1" height="26" alt=""></td> </tr> <tr> <td> <a href="http://www.Poetsproduct.nl/Contact.php"> <img src="images/New-15-07_35.png" alt="" width="156" height="24" border="0" id="Image6" onMouseOver="MM_swapImage('Image6','','Rollover/images/New-15-07_35.png',1)" onMouseOut="MM_swapImgRestore()"></a></td> <td> <img src="images/spacer.gif" width="1" height="24" alt=""></td> </tr> <tr> <td> <img src="images/New-15-07_37.png" width="156" height="13" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="13" alt=""></td> </tr> <tr> <td rowspan="6"> <img src="images/New-15-07_38.png" width="56" height="584" alt=""></td> <td colspan="3"> <img src="images/New-15-07_39.png" width="158" height="29" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="29" alt=""></td> </tr> <tr> <td width="158" height="134" colspan="3" align="left" valign="top" background="images/New-15-07_40.png" alt=""><p><a href="#" onClick="javascript:window.open('https://www.paypal.com/nl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350');"> <img src="images/Paypal.png" alt="Paypal" width="158" height="70" border="0"></a><span style="font-size: 12px"> U kunt ook uw bankrekening koppelen aan uw Paypal account.</span></p></td> <td> <img src="images/spacer.gif" width="1" height="134" alt=""></td> </tr> <tr> <td colspan="3"> <img src="images/New-15-07_41.png" width="158" height="8" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="8" alt=""></td> </tr> <tr> <td rowspan="3"> <img src="images/New-15-07_42.png" width="1" height="413" alt=""></td> <td colspan="2"> <img src="images/New-15-07_43.png" width="157" height="30" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="30" alt=""></td> </tr> <tr> <td rowspan="2"> <img src="images/New-15-07_44.png" width="1" height="383" alt=""></td> <td width="156" height="154" align="left" valign="top" background="images/New-15-07_45.png" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;" alt="">Wij staan ingeschreven in het handelsregister bij de Kamer van Koophandel onder nummer: 53150074.</td> <td> <img src="images/spacer.gif" width="1" height="154" alt=""></td> </tr> <tr> <td> <img src="images/New-15-07_46.png" width="156" height="229" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="229" alt=""></td> </tr> <tr> <td> <img src="images/spacer.gif" width="56" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="156" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="10" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="104" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="2" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="20" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="3" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="20" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="3" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="20" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="21" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="307" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="135" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="227" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="10" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="104" height="1" alt=""></td> <td></td> </tr> </table> </body> </html> Please help, I really cant figure it out Thanks, Mitch [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/242266-problems-with-my-join-form/ Share on other sites More sharing options...
conker87 Posted July 18, 2011 Share Posted July 18, 2011 Doesn't ereg_replace() replace the matched text in pattern with the replacement? Thus removing all the correct values? Quote Link to comment https://forums.phpfreaks.com/topic/242266-problems-with-my-join-form/#findComment-1244202 Share on other sites More sharing options...
Dominee Posted July 18, 2011 Author Share Posted July 18, 2011 Still didnt solved the problem Quote Link to comment https://forums.phpfreaks.com/topic/242266-problems-with-my-join-form/#findComment-1244225 Share on other sites More sharing options...
Psycho Posted July 18, 2011 Share Posted July 18, 2011 Yeah, but it doesn't look like ereg_replace() is being used on the email field. Where it is being used it is just removing any characters that are not a-z, 0-9 and - in a few cases - the space character. I've looked over the code a couple of times and don't see anything that would cause the $email value to be considered empty. The $_POST reference is using the same index name as set in the form. Try adding some debugging code to validate the values through the processing. Try replacing this $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); With this to see if the results are what you'd expect. echo "<pre>".print_r($_POST, TRUE)."</pre>"; //Debug line $email = stripslashes($_POST['email']); echo "Email after stripslashes: $email<br>\n"; //Debug line $email = strip_tags($email); echo "Email after striptags: $email<br>\n"; //Debug line $email = mysql_real_escape_string($email); echo "Email after mysql_real_escape_string: $email<br>\n"; //Debug line Quote Link to comment https://forums.phpfreaks.com/topic/242266-problems-with-my-join-form/#findComment-1244249 Share on other sites More sharing options...
Dominee Posted July 19, 2011 Author Share Posted July 19, 2011 Thanks for your reply but it does not work I will get this error if I replace the codes like you said. Array ( [username] => TestTest [country] => Nederland [state] => State [city] => City [accounttype] => a => [email protected] [password] => Pass [submit] => Submit Form ) Email after stripslashes: [email protected] Email after striptags: [email protected] Email after mysql_real_escape_string: Quote Link to comment https://forums.phpfreaks.com/topic/242266-problems-with-my-join-form/#findComment-1244483 Share on other sites More sharing options...
Psycho Posted July 19, 2011 Share Posted July 19, 2011 Thanks for your reply but it does not work Yes it did work, the debugging code wasn't meant to solve the problem, it was meant to identify where the problem is - and it did exactly that. The problem is that after you run mysql_real_escape_string() on the value it is coming up empty. The only thing I can conclude is that either you haven't connected to the MySQL database before running that line or 2) you are not using MySQL. In either case I would expect errors to be displayed, but maybe you are suppressing errors? All I can see is that you have the following line before using mysql_real_escape_string(). include_once "connect_to_mysql.php"; I would assume that is used to connect to the database, but I can't verify that or that you have added appropriate error handling. Quote Link to comment https://forums.phpfreaks.com/topic/242266-problems-with-my-join-form/#findComment-1244646 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.