austinthompson Posted January 2, 2012 Share Posted January 2, 2012 I have a script where people can register to use my site but it does not work. I did not write this script I downloaded it. I thought I fixed it but it does not work no matter what I do. I am uploading the original unedited version of this page in case a modification I made is part of the problem. Thanks. 17230_.php Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/ Share on other sites More sharing options...
abrahamgarcia27 Posted January 2, 2012 Share Posted January 2, 2012 this is what i would do my code may not be the best, but it works. There is still alot of styling to be done. Hope it helps! <?php //connect to your database $connection = mysql_connect("localhost","user","password"); if (!$connection) { die('Could not connect: ' . mysql_error()); } //message if query successful $message= $_GET['m']; if ($message == "1"){ //select query and choose database mysql_select_db("database", $connection); $result = mysql_query("SELECT * FROM people WHERE admin=1"); while($row = mysql_fetch_array($result)) { $to = $row['email'].","; //post variables $fname = $_POST['fname']; $lname = $_POST['lname']; $suffix = $_POST['suffix']; $userid = $_POST['userid']; $email = $_POST['email']; $comment= $_POST['comment']; //send the emails $subject = "Request for new WishList account"; $message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment;$headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com"; mail($to,$subject,$message,$headers); } //echo content echo "<h2>Thank you. You should receive an email shortly with your account details</h2>" ; }else { //main form echo '<HTML> <link rel=stylesheet href=style.css type=text/css> <title>Sign Up </title> <BODY> <table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)"> <tr> <td valign="top"> "<center>" The following information will be submitted to the administrator of the WishList Site who will create an account for you. You will receive an email with your WishList password when the account is created. </td></tr></table> <p> <form method=post action="registerUser.php?m=1"> <table style="border-collapse: collapse;" id="AutoNumber1" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" bgcolor=lightYellow> <tr><td colspan="2" align="center" bgcolor="#6702cc"> <font size=3 color=white><b>Please Fill In</b></font> </td></tr> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=fname size=20></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=lname size=20></td> </tr> <tr> <td align=right><b>Suffix</b></td> <td><input type=text name=suffix size=20></td> </tr> <tr> <td align=right><b>Desired Userid</b></td> <td><input type=text name=userid size=20></td> </tr> <tr> <td align=right><b>Email</b></td> <td><input type=text name=email size=40></td> </tr> <tr> <td align=right><b>Comment</b></td> <td><textarea name=comment rows=3 cols=60></textarea></td> </tr> <tr><td align="center" colspan="2" bgcolor="#c0c0c0"> <input type="submit" value="Submit" style="font-weight:bold"> </td></tr> </table> </form> "</center>" </td> </tr> </table> </body> </html>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303194 Share on other sites More sharing options...
austinthompson Posted January 2, 2012 Author Share Posted January 2, 2012 Is it me or is something wrong? I get an error at line 50 and when I look at the way you posted it all the code posts red at the <html> tag. Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303242 Share on other sites More sharing options...
abrahamgarcia27 Posted January 2, 2012 Share Posted January 2, 2012 yeah you are going to have to clean that code up because there is alot of syntax error on the html form Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303244 Share on other sites More sharing options...
austinthompson Posted January 2, 2012 Author Share Posted January 2, 2012 So the HTML i have is jacked up but the PHP coding is right? Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303258 Share on other sites More sharing options...
trq Posted January 2, 2012 Share Posted January 2, 2012 The code abrahamgarcia27 posted doesn't actually register a user, it simply sends the user an email saying that an admin will register them shortly. You will need to post a description of what your actual problem is (this doesn't work is not descriptive enough for us to be able to assist you). It's always best to post the relevant code directly within your post using tags. People won't often download code. Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303259 Share on other sites More sharing options...
austinthompson Posted January 2, 2012 Author Share Posted January 2, 2012 The code abrahamgarcia27 posted doesn't actually register a user, it simply sends the user an email saying that an admin will register them shortly. You will need to post a description of what your actual problem is (this doesn't work is not descriptive enough for us to be able to assist you). It's always best to post the relevant code directly within your post using tags. People won't often download code. Sorry. Super noob mistake. Ok, let me try this again. The code I have displays what you see here: http://www.alliwantfor.me/registerUser.php That is the first problem. There is no way to register because it tells you "Too many requests have been made within the last hour. This feature has been temporarily disabled." If I delete the part of the code that displays that statement then it appears to work correctly and gives you a form. That form does nothing once submitted. That version is located at: http://www.alliwantfor.me/fix.php Here is the original code found at: http://www.alliwantfor.me/registerUser.php <?php $ignoreSession = true; include "funcLib.php"; $stop = true; ?> <HTML> <head> <link rel=stylesheet href=style.css type=text/css> <title>Sign Up </title> </head> <BODY> <table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)"> <tr> <td valign="top"> <center> <?php if($_REQUEST["fname"] != ""){ if($stop){ return; } $fname = convertString($_REQUEST["fname"]); $lname = convertString($_REQUEST["lname"]); $suffix = convertString($_REQUEST["suffix"]); $userid = convertString($_REQUEST["userid"]); $email = convertString($_REQUEST["email"]); $comment = convertString($_REQUEST["comment"]); // send an email out to all the admins $query = "select * from people where admin=1"; $result = mysql_query($query) or die("Could not query: " . mysql_error()); $to = ""; while($row = mysql_fetch_assoc($result)){ $to .= $row["email"] . ","; } $subject = "Request for new WishList account"; $message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment; $result = sendEmail($to, "", $subject, $message, 0); if($result == 1) print "<h2>Thank you. You should receive an email shortly with your account details</h2>"; else print "<h1>An unexpected error has occured</h1>"; } else{ ?> <h2>Welcome to the WishList Site</h2> <table width=80%><tr><td align=left> <?php if($stop){ print "Too many requests have been made within the last hour. This feature has been temporarily disabled."; return; } ?> The following information will be submitted to the administrator of the WishList Site who will create an account for you. You will receive an email with your WishList password when the account is created. </td></tr></table> <p> <form method=post action="registerUser.php"> <table style="border-collapse: collapse;" id="AutoNumber1" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" bgcolor=lightYellow> <tr><td colspan="2" align="center" bgcolor="#6702cc"> <font size=3 color=white><b>Please Fill In</b></font> </td></tr> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=fname size=20></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=lname size=20></td> </tr> <tr> <td align=right><b>Suffix</b></td> <td><input type=text name=suffix size=20></td> </tr> <tr> <td align=right><b>Desired Userid</b></td> <td><input type=text name=userid size=20></td> </tr> <tr> <td align=right><b>Email</b></td> <td><input type=text name=email size=40></td> </tr> <tr> <td align=right><b>Comment</b></td> <td><textarea name=comment rows=3 cols=60 onfocus="this.value=''"></textarea></td> </tr> <tr><td align="center" colspan="2" bgcolor="#c0c0c0"> <input type="submit" value="Submit" style="font-weight:bold"> </td></tr> </table> </form> </center> </td> </tr> </table> </body> </html> <?php } ?> Here is the code posted at: http://www.alliwantfor.me/fix.php <?php $ignoreSession = true; include "funcLib.php"; $stop = true; ?> <HTML> <head> <link rel=stylesheet href=style.css type=text/css> <title>Sign Up </title> </head> <BODY> <table cellspacing="0" cellpadding="5" width="100%" height="100%" bgcolor="#FFFFFF" nosave border="0" style="border: 1px solid rgb(128,255,128)"> <tr> <td valign="top"> <center> <?php if($_REQUEST["fname"] != ""){ if($stop){ return; } $fname = convertString($_REQUEST["fname"]); $lname = convertString($_REQUEST["lname"]); $suffix = convertString($_REQUEST["suffix"]); $userid = convertString($_REQUEST["userid"]); $email = convertString($_REQUEST["email"]); $comment = convertString($_REQUEST["comment"]); // send an email out to all the admins $query = "select * from people where admin=1"; $result = mysql_query($query) or die("Could not query: " . mysql_error()); $to = ""; while($row = mysql_fetch_assoc($result)){ $to .= $row["email"] . ","; } $subject = "Request for new WishList account"; $message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment; $result = sendEmail($to, "", $subject, $message, 0); if($result == 1) print "<h2>Thank you. You should receive an email shortly with your account details</h2>"; else print "<h1>An unexpected error has occured</h1>"; } else{ ?> <h2>Welcome to the WishList Site</h2> <table width=80%><tr><td align=left> The following information will be submitted to the administrator of the WishList Site who will create an account for you. You will receive an email with your WishList password when the account is created. </td></tr></table> <p> <form method=post action="registerUser.php"> <table style="border-collapse: collapse;" id="AutoNumber1" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" bgcolor=lightYellow> <tr><td colspan="2" align="center" bgcolor="#6702cc"> <font size=3 color=white><b>Please Fill In</b></font> </td></tr> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=fname size=20></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=lname size=20></td> </tr> <tr> <td align=right><b>Suffix</b></td> <td><input type=text name=suffix size=20></td> </tr> <tr> <td align=right><b>Desired Userid</b></td> <td><input type=text name=userid size=20></td> </tr> <tr> <td align=right><b>Email</b></td> <td><input type=text name=email size=40></td> </tr> <tr> <td align=right><b>Comment</b></td> <td><textarea name=comment rows=3 cols=60 onfocus="this.value=''"></textarea></td> </tr> <tr><td align="center" colspan="2" bgcolor="#c0c0c0"> <input type="submit" value="Submit" style="font-weight:bold"> </td></tr> </table> </form> </center> </td> </tr> </table> </body> </html> <?php } ?> Hopefully this is a better explination. Thanks for your help guys. Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303261 Share on other sites More sharing options...
abrahamgarcia27 Posted January 2, 2012 Share Posted January 2, 2012 do you want to store the people that register to your site in a database? Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303264 Share on other sites More sharing options...
austinthompson Posted January 2, 2012 Author Share Posted January 2, 2012 yes. a mysql database Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303319 Share on other sites More sharing options...
abrahamgarcia27 Posted January 2, 2012 Share Posted January 2, 2012 this code will insert to a database as well as to send the email that there has been a new user registered <?php //connect to your database $connection = mysql_connect("localhost","root","pass"); if (!$connection) { die('Could not connect: ' . mysql_error()); } //message if query successful $message= $_GET['m']; if ($message == "1"){ //insert infomation to database mysql_select_db("databse", $connection); $sql="INSERT INTO people (fname, lname, suffix, userid, email, comment, admin) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[suffix]', '$_POST[userid]', '$_POST[email]' , '$_POST[comment]', '0')"; if (!mysql_query($sql,$connection)) { die('Error: ' . mysql_error()); } //select query and choose database $result = mysql_query("SELECT * FROM people WHERE admin=1"); while($row = mysql_fetch_array($result)) { $to = $row['email']; } //post variables $fname = $_POST['fname']; $lname = $_POST['lname']; $suffix = $_POST['suffix']; $userid = $_POST['userid']; $email = $_POST['email']; $comment= $_POST['comment']; //send the emails $subject = "Request for new WishList account"; $message = "The following person is requesting a new account<p><b>First Name:</b> " . $fname . "<br><b>Last Name:</b> " . $lname ."<br><b>Suffix:</b> " . $suffix . "<br><b>Desired Userid:</b> " . $userid . "<br><b>Email:</b> " . $email . "<br><b>Comment</b><br>" .$comment;$headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com"; mail($to,$subject,$message,$headers); //echo content echo "<HTML> <link rel=stylesheet href=style.css type=text/css> <title>Sign Up </title> <BODY> <table cellspacing='0' cellpadding='5' width='100%' height='100%' bgcolor='#FFFFFF' nosave border='0' style='border: 1px solid rgb(128,255,128)'> <tr> <td valign='top'> <center><h2>Thank you. You should receive an email shortly with your account details</h2> </center> </td> </tr> </table> </body> </html>" ; }else { //main form echo "<HTML> <link rel=stylesheet href=style.css type=text/css> <title>Sign Up </title> <BODY> <table cellspacing='0' cellpadding='5' width='100%' height='100%' bgcolor='#FFFFFF' nosave border='0' style='border: 1px solid rgb(128,255,128)'> <tr> <td valign='top'> <center> The following information will be submitted to the administrator of the WishList Site who will create an account for you. You will receive an email with your WishList password when the account is created. <p> <form method=post action='registerUser.php?m=1'> <table style='border-collapse: collapse;' id='AutoNumber1' border='0' bordercolor='#111111' cellpadding='2' cellspacing='0' bgcolor=lightYellow> <tr><td colspan='2' align='center' bgcolor='#6702cc'> <font size=3 color=white><b>Please Fill In</b></font> </td></tr> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=fname size=20></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=lname size=20></td> </tr> <tr> <td align=right><b>Suffix</b></td> <td><input type=text name=suffix size=20></td> </tr> <tr> <td align=right><b>Desired Userid</b></td> <td><input type=text name=userid size=20></td> </tr> <tr> <td align=right><b>Email</b></td> <td><input type=text name=email size=40></td> </tr> <tr> <td align=right><b>Comment</b></td> <td><textarea name=comment rows=3 cols=60></textarea></td> </tr> <tr><td align='center' colspan='2' bgcolor='#c0c0c0'> <input type='submit' value='Submit' style='font-weight:bold'> </td></tr> </table> </form> </center> </td> </tr> </table> </body> </html>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303428 Share on other sites More sharing options...
austinthompson Posted January 3, 2012 Author Share Posted January 3, 2012 Ok, now I am confused. This does not work either. Why are there 2 sets of "html" tags? Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303563 Share on other sites More sharing options...
abrahamgarcia27 Posted January 3, 2012 Share Posted January 3, 2012 this one works, but there is no validation so if you submit form without any values it still runs the query and inserts values and sends email. it is working i have it hosted here http://phedx.azsurveillance.net/scripts_trials/freaks/registerUser.php there is two html tags because the 2nd html is the main form after the form is submitted the form submit and goes to the following url http://phedx.azsurveillance.net/scripts_trials/freaks/registerUser.php?m=1 if you see the script it says if the message = 1 it will echo thank you you have succesfully registered if not it will echo the main form this is why it has two html tags Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303564 Share on other sites More sharing options...
austinthompson Posted January 3, 2012 Author Share Posted January 3, 2012 Thanks! Looks good. Let me see how it works on my server. Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303575 Share on other sites More sharing options...
austinthompson Posted January 3, 2012 Author Share Posted January 3, 2012 can you email me the file you have? No matter what I do, i can not get the code to work right when I copy and paste it. Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303587 Share on other sites More sharing options...
abrahamgarcia27 Posted January 3, 2012 Share Posted January 3, 2012 have you created your mysql database already? maybe thats why it is not working 17249_.php Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303642 Share on other sites More sharing options...
austinthompson Posted January 3, 2012 Author Share Posted January 3, 2012 Yes. the script creates a database on the first run. Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303876 Share on other sites More sharing options...
abrahamgarcia27 Posted January 3, 2012 Share Posted January 3, 2012 well the script that i uploaded doesn't actually create the database it just refers to it you have to create the database yourself. Did you already do this my databse is composed of the following. CREATE TABLE IF NOT EXISTS `people` ( `id` int(10) NOT NULL AUTO_INCREMENT, `email` varchar(200) NOT NULL, `admin` int(1) NOT NULL, `fname` varchar(300) NOT NULL, `lname` varchar(300) NOT NULL, `suffix` varchar(50) NOT NULL, `userid` varchar(100) NOT NULL, `comment` varchar(500) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; http://phedx.azsurveillance.net/scripts_trials/freaks/people.sql you can download it here Quote Link to comment https://forums.phpfreaks.com/topic/254182-why-is-my-registration-page-not-working/#findComment-1303912 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.