BillyBoB Posted July 15, 2006 Share Posted July 15, 2006 ok heres the code tell me if there is an error :([code]<?phpecho(" <center> <form method=\"POST\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br /> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br /> Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br /> Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"emai1\"><br /> <input name=\"register\" type=\"submit\" value=\"Register\"> </form> </center>");if($_POST[submit]){ $username = $_POST[username]; $password = $_POST[pass]; $cpassword = $_POST[cpass]; $email = $_POST[email]; if($pass==$cpass) { $password = md5($password); $checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error()); $checkname= mysql_num_rows($checkname) or die(mysql_error()); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error()); $checkemail = mysql_num_rows($checkemail) or die(mysql_error()); if ($checkemail>0|$checkname>0) { echo "The username or email is already in use"; }else{ $username = htmlspecialchars($username); $password = htmlspecialchars($password); $email = htmlspecialchars($email); $query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error()); $getuser = mysql_query("SELECT * FROM users where username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($getuser) or die(mysql_error()); $profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error()); echo "You have successfully registered!"; } }else{ echo("Your passwords don't match!"); }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/ Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 how about YOU tell US what's wrong. is it not submitting, is it not processing, do you get a parse error, is it a blank page? what's the issue? Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58349 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 What you mean is there an error you tell us!Sort out your form!loads or errors man dam lol......................<form method="post" action"">// this is minium//anotherif($_POST['submit']){code}about a 30 of them lol............are you blind weres the $_POST[' '];man.what the hell is this about lol.....bad code pratice ok.if ($checkemail>0|$checkname>0) Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58350 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 Dude, yea. Tell us what error you get. Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58351 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 its just not sending srry for the late replay i was playing cs lol by saying sending sending to the database Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58365 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 dude it works without the ' ' i have built this page b4 but now its now working i didnt build the exact page tho Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58366 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 i have know read your code and pointed out a lot nearly all lol..........but you continue to give advice make me laugh change all that i ask ok.ps. you was also advised to use session ok try them, the $_SESSION code is better then the cookie code your using ok.[code]<?php//This dosent need echoing 1 problam you can use html then start php.echo(" <center>//This needs table html problam agin. <form method=\"POST\">// This form is incorrect look up forms. Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br /> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br /> Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br /> Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"emai1\"><br /> <input name=\"register\" type=\"submit\" value=\"Register\"> </form> </center>");if($_POST[submit])//this is wrong first the sytex wrong secondly you got the name wrong its called register as set in your form $_POST['register']{All the $_POST[' '] wrong all need single quotes. $username = $_POST[username]; $password = $_POST[pass]; $cpassword = $_POST[cpass]; $email = $_POST[email]; if($pass==$cpass) { $password = md5($password);// your doing a double sql statement when you can use one...... $checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error()); $checkname= mysql_num_rows($checkname) or die(mysql_error()); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error()); // dont like this bad code pratice to use this sort of valadating code change it.$checkemail = mysql_num_rows($checkemail) or die(mysql_error()); if ($checkemail>0|$checkname>0) { echo "The username or email is already in use"; }else{// where the addslashes example name=addslashes($name); $username = htmlspecialchars($username); $password = htmlspecialchars($password); $email = htmlspecialchars($email); $query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error());// Dont know why this here!$getuser = mysql_query("SELECT * FROM users where username = '$username'") or die(mysql_error());$user = mysql_fetch_array($getuser) or die(mysql_error()); $profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error()); echo "You have successfully registered!"; } }else{ echo("Your passwords don't match!"); }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58367 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 lolall of this is inside of a table on my site just didnt want to post all that its long Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58368 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 man ur script is too long and confusing maybe if u would put it in the bbcode for codeit would look a lot better and use the tabs better u have to tab everything inside the if then if there is another if then tab all of it too lol Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58370 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 For a man that gives others advice you havenot seen why you can not post joke.you got post submit and called it register why?if($_POST['register'] {} Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58373 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 ok i think i got it now first the validations werent right then the submit problem i made this code first off a tutorial then off my old site so thats why i just started really making database driven sites but i all clicks in my head fast'NOTE: "Why is my karma so bad i don't get it i had +1 -1 now i have -2" Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58376 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 [code]<?phpecho(" <center> <form method=\"POST\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br /> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br /> Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br /> Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"emai1\"><br /> <input name=\"register\" type=\"submit\" value=\"Register\"> </form> </center>");if($_POST[register]){ $username = $_POST[username]; $password = $_POST[pass]; $cpassword = $_POST[cpass]; $email = $_POST[email]; if($password==$cpassword) { $password = md5($password); $checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error()); $checkname= mysql_num_rows($checkname) or die(mysql_error()); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error()); $checkemail = mysql_num_rows($checkemail) or die(mysql_error()); if ($checkemail>0|$checkname>0) { echo "The username or email is already in use"; }else{ $username = htmlspecialchars($username); $password = htmlspecialchars($password); $email = htmlspecialchars($email); $query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error()); $getuser = mysql_query("SELECT * FROM users where username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($getuser) or die(mysql_error()); $profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error()); echo "You have successfully registered!"; } }else{ echo("Your passwords don't match!"); }}?>[/code]this is what i have post the fixed version plzEDIT: why do u hate me redarrow? Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58377 Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 in case you didn't catch what the problem was in the first place, you hadn't set an action="" attribute for the <form> tag. it had no idea where to submit the form.EDIT: my mistake on that one, thanks thorpe.are you getting no echoing at all after the form is submit? and you have it right the first time, the name of the submit button is "register" so it sends $_POST['register'], not $_POST['submit']. Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58378 Share on other sites More sharing options...
trq Posted July 15, 2006 Share Posted July 15, 2006 [quote]in case you didn't catch what the problem was in the first place, you hadn't set an action="" attribute for the <form> tag. it had no idea where to submit the form.[/quote]action nor method are both not required in a form. By default, action will send back to itself, by default, method will be GET. Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58382 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 thank u dude action is a cgi i dont use cgi and i find it funny i have 10 other working pages with out the action field and they work fine Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58383 Share on other sites More sharing options...
trq Posted July 15, 2006 Share Posted July 15, 2006 [quote]action is a cgi[/quote]That makes no sense. You can point your action toward a .php script, not just cgi. It just happens to be that without an action, the form will submit to itself. Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58385 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 ok if u guys think its such a great idea to put an action in tell the exact code to put in plzEDIT:ok heres the latest code plz help[code]<?phpecho(" <center> <form method=\"POST\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\" /><br /> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\" /><br /> Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\" /><br /> Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"email\" /><br /> <input name=\"submit\" type=\"submit\" value=\"Register\" /> </form> </center>");if($_POST['submit']){ $username = $_POST['username']; $password = $_POST['pass']; $cpassword = $_POST['cpass']; $email = $_POST['email']; if($password==$cpassword) { $password = md5($password); $checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error()); $checkname= mysql_num_rows($checkname) or die(mysql_error()); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error()); $checkemail = mysql_num_rows($checkemail) or die(mysql_error()); if ($checkemail>0|$checkname>0) { echo "The username or email is already in use"; }else{ $username = htmlspecialchars($username); $password = htmlspecialchars($password); $email = htmlspecialchars($email); $query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error()); $getuser = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($getuser) or die(mysql_error()); $profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error()); echo "You have successfully registered!"; } }else{ echo("Your passwords don't match!"); }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58387 Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 perhaps you should review your HTML knowledge before you dive right into PHP programming.[code]<form action="pagetosendtheforminfoto.php" method="post"></form>[/code]regardless, you're still not answering the question we need to know: are you getting NOTHING being echoed to the page, is the submit button not doing anything, are you not getting registered, or what? Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58389 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 see thats the prob i dont want to send it to anything and i know html but i dont send the form to a page in html either srry Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58390 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 ok here is the problem i posted it already but here it is:The information doesn't go to the database.heres is the codeing:[code]<?phpecho(" <center> <form method=\"POST\"> Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\" /><br /> Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\" /><br /> Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\" /><br /> Email: <input type=\"text\" size=\"15\" maxlength=\"50\" name=\"email\" /><br /> <input name=\"submit\" type=\"submit\" value=\"Register\" /> </form> </center>");if($_POST['submit']){ $username = $_POST['username']; $password = $_POST['pass']; $cpassword = $_POST['cpass']; $email = $_POST['email']; if($password==$cpassword) { $password = md5($password); $checkname = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error()); $checkname= mysql_num_rows($checkname) or die(mysql_error()); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'") or die(mysql_error()); $checkemail = mysql_num_rows($checkemail) or die(mysql_error()); if ($checkemail>0|$checkname>0) { echo "The username or email is already in use"; }else{ $username = htmlspecialchars($username); $password = htmlspecialchars($password); $email = htmlspecialchars($email); $query = mysql_query("INSERT INTO users (username, password) VALUES('$username','$password')") or die(mysql_error()); $getuser = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($getuser) or die(mysql_error()); $profile = mysql_query("INSERT INTO profile (id,username,rank,email) VALUES('$user[id]','$user[username]','1','$email')") or die(mysql_error()); echo "You have successfully registered!"; } }else{ echo("Your passwords don't match!"); }}?>[/code]EDIT: if you want to see the page in action then heres the link:[url=http://dreamshowstudios.net/register.php]http://dreamshowstudios.net/register.php[/url] Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58391 Share on other sites More sharing options...
akitchin Posted July 15, 2006 Share Posted July 15, 2006 youve got an error with your mysql_fetch_array() is my guess. its die()ing, but there is no mysql_error() since the previous query went off fine. it's just not a valid resource. try removing the or die() from the mysql_fetch_array() and you might find something.if you need the ID that MySQL auto-inserted in the previous query, use mysql_insert_id(). don't grab it from the database, as that wastes resources. Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58393 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 let me go try all that brb Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58396 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 which one of the or die(mysql_error());did u want me to remove? Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58397 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Author Share Posted July 15, 2006 ok though all ur i dont like this section of coding i have found the error since most of this coding wasnt updated for the new databases i hadnt made the script check the emails in the profile srry for the big mess and will someone plz tell me why my karma is bad plz Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58398 Share on other sites More sharing options...
scheols Posted July 15, 2006 Share Posted July 15, 2006 why dont you do $password = md5($_POST['pass']);instead of$password = $_POST[pass];and remove:$password = md5($password); Quote Link to comment https://forums.phpfreaks.com/topic/14648-i-cant-find-my-error-in-my-registerphp-in-notepad/#findComment-58402 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.