Jump to content

mondo

Members
  • Posts

    8
  • Joined

  • Last visited

mondo's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Man! Just when i thought this would work. I'm getting the same error again "Cannot modify header information - headers already sent " that is on this line....header("Location: error-account.php");What does it mean it has already been sent? Also, i noticed that you added a password for the sql connect. I was gettin an error for that until i took the pass out. Oh yea, the reason there was only 44 lines was because i erased all of the "notes" before posting the code.Anyone know whats goin on with that error? Should i just take that line out?Heres the full code again, i hope this is not annoying you guys as much as it is for me. <?php $url = 'http://www.-------.com'; $user = $_POST['username']; $pass = $_POST['password']; $pass2 = $_POST['password2']; $zip = $_POST['zip']; $email = $_POST['email']; $min_lenngth = 6; function CheckMail($email){ if(eregi("@", $email)){ return true; }else { return false; } } function CheckZip($zip) { if (eregi("[0-9]", $zip)){ return true; }else{ return false; } } if (($pass)!=($pass2)){ echo "Passwords to not match!"; exit; }elseif((empty($email)) || (!CheckMail($email))){ echo "E-mail is not valid"; exit; }elseif(strlen($user) < $min_lenngth || strlen($pass) < $min_lenngth){ echo "Password and or username is too short"; exit; }else{ echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; }?><?php$link = mysql_connect("localhost", "root", "");@mysql_select_db("users") or die( "Unable to select database");$sql="SELECT username FROM users WHERE username='".$user."'";$check = mysql_query($sql);$returned = mysql_fetch_array($check);if(!empty($returned)){ header("Location: error-userexists.php"); mysql_close($link); Die();}$sql2="SELECT email FROM users WHERE email='".$email."'";$check = mysql_query($sql2);$returned = mysql_fetch_array($check);if(!empty($returned)){header("Location: error-emailexists.php");mysql_close($link);Die();}$pass=md5($pass);$request = "INSERT INTO users values(NULL,'".$user."','".$pass."', '".$email."','".$zip."',)";$results = mysql_query($request);if($results){header("Location: accountok.php");}else {header("Location: error-account.php");}mysql_close($link);?>
  2. Thanks guys, still having problems like usaul! This is the error message i get Line 79 = header("Location: error-account.php"); ( I don't see what the problem is, perhaps ive yet to create an error-account file?)Line 83 = mysql_close($link);Heres the entire code. Might get a btter understanding. <?php mysql_connect("localhost", "root", "");mysql_select_db(users) or die( "Unable to select database");$check = mysql_query("select username from users where username=\"$user\"");$returned = mysql_fetch_array($check);if(!empty($returned)){header("Location: error-userexists.php"); mysql_close($connection); Die();}else{$check = mysql_query("select email from users where email=\"$email\"");$returned = mysql_fetch_array($check);if(!empty($returned)){header("Location: error-emailexists.php"); mysql_close($link); Die();}else $pass=md5($pass); $request = "INSERT INTO users values(NULL,\'$user\',\'$pass\', \'$email\',\'$zip\',)";$results = mysql_query($request);if($results) {header("Location: accountok.php"); }else {header("Location: error-account.php");}mysql_close($link); Die();?>
  3. Im having a problem connection to my database on my local machine Here is the code i am using... <?php mysql_connect("mysqlhost", "users", "users");@mysql_select_db(users) or die( "Unable to select database");$check = mysql_query("select username from users where username=\"$user\"");$returned = mysql_fetch_array($check);if(!empty($returned)){header("Location: error-userexists.php"); mysql_close($connection); Die();}else{$check = mysql_query("select email from users where email=\"$email\"");$returned = mysql_fetch_array($check);if(!empty($returned)){header("Location: error-emailexists.php"); mysql_close($link); Die();}else $pass=md5($pass); $request = "INSERT INTO users values(NULL,\'$user\',\'$pass\', \'$email\',\'$zip\',)";$results = mysql_query($request);if($results) {header("Location: accountok.php"); }else {header("Location: error-account.php");}mysql_close($link); Die();?> I am using PHPmyadmin for my database. Im not sure if this is actually mysql .Im guessing "mysql_connect("mysqlhost", "users", "users");" mysqlhost = my IP addressusers = Database nameusers = TablesCan someone school me on this real quick?
  4. I thank you all so much!!!! The new script works perfectly!! You guys have lifted a huge load off my back, thanks again!
  5. Someguy, www.mehalism.com has fixed up the script for me and that is going well. I thank you for your knowledge also. I'm still having this problem with the error-email.php file. The form i created is suppossed to "post" the data into this page im having problems with now. If i type in a username with less than 6 characters or the passwords do not much , im redirected to error-email.php no matter what! The script has been checked multiple times and no errors found in the code, so why does it continue to do this?
  6. Ok, i tried it out and it is still redirecting me to error-email.php. Everything else is fine. Thanks for your help.
  7. <?php $url = \'http://www.yourdomain.com/accountok.php\'; // Where to redirect //the user after that form has been processed successfully. Now we will //get the values sent by the form: to get a value you can generally access //it with $_POST[\'valuename\'] where valuename is the string you put into //the value of the the field you are accessing$user = $_POST[\'username\'];//get username from form$pass = $_POST[\'password\'];//get password from form$pass2 = $_POST[\'password2\'];//get password2 from form$zip = $_POST[\'zip\'];//get zip from form$email = $_POST[\'email\'];//get email from form//now that we have picked all the values we need from the form we can //start checking them one at a time//PASSWORD VERIFICATIONif (($pass)!=($pass2)) //if the values stored in the 2 variables are //different we redirect the users to a previously created error page{ header("Location: error-pwverify.php"); //the user will be sent to this page Die();}//EMAIL VERIFICATIONfunction CheckMail($email) // this function checks if the email format is ok, //if the chars are allowed, if there are enough chars in the TLD learn more //about eregi function here: http://www.php.net/manual/en/function.eregi.php{if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$",$email)) { return true; } else { return false; }}if ((empty($email)) || (!CheckMail($email))) //here we check if the email is //empty and if the previous function controls are passed, if there are //errors the user is sent to a previously prepared custom error page{ header("Location: error-email.php"); //the user will be sent to this page Die();}//ZIP CODE VERIFICATIONfunction CheckZip($zip) { if (eregi("[0-9]", $zip)) //here we check if the ZIP code contains only numbers { return true; } else { return false; }}if ((empty($zip)) || (!CheckZip($zip)) || (strlen($zip)!=5))//if the ZIP code is empty, the CheckZip function fails or the code length is //different from 5 chars the user is sent to a previously prepared custom error page{ header("Location: error-zip.php"); //the user will be sent to this page Die();}//USER AND PASSWORD LENGTH CHECK$min_lenngth = 6; //this value is the minimal length that we desire our passwords //to be if the username or the password is shorter than 6 chars the user is sent //to a previously prepared custom error pageif(strlen($user) < $min_lenngth || strlen($pass) < $min_lenngth){ header("Location: error-pwshort.php"); //the user will be sent to this page Die();}//NOTE: insert here the code between //****************// and //****************// //in the following part of the tutorial if you want to add these values to your //database//NOTE:don\'t use the following code line (erase it) if you inserted here the code //to add the values to the database//if all our checks are passed we go to the url assigned at the top to the variable urlecho <META HTTP-EQUIV=Refresh CONTENT="0; URL=.$url.">;?>
  8. Hey guys, first let me say im a complete newbie to php , i have encountered problems before that i have fixed on my own. But this right here is driving me nuts.Im in thr process of creating a registration form with validation and then sending the values to my database using Dreamweaver. Im following This Tutorial For a better understanding of what my problems are i have some screenshots Problem 1 As you can see, with the foward slashes in that line, the rest of the coding is in red. Im guessing that means an error. I check in my browser and it is indeed an error. Was the guy that wrote this tutorial wrong? Problem 2 When i take the backslashes out, everything seems to go well until it gets to the first value. That is highlighted in blue but the rest is still red Problem 3 When i take all of the values out, everything seems to go fine. Problem 4 Now, the tag to end php here is in the dark red. I get an error when its like this . I also get an error with the "META HTTP EQUIV" code right above that also Problem 5 For some reason when i add a comma before the end php tag, its seem to work.Also, im guessing the whole idea of this script in that part of the tutorial is to validate the user input from the form before that. If soemthing is wrong, they get an error message. If it is alright they are suppossed to get redirected to another page. For some reason, when all feilds are correct, instead of redirectign me to the correct page, i get brought to the "user email error" page.I am completely frustrated and would like to know what the problems are and how to solve them. Im pretty sure they are the smallest most simple things too. I appreciate all the help, and thanks in advance.
×
×
  • Create New...