PHP - Registration Form Trying To Add If Empty Thing To It... Page Shows Up White.
Similar TutorialsWhat I am looking for is that if any field in a database is empty, the form comes back and puts in the word "empty" into the web page, but not the database. I got this right now, it shows the first part fine, but the second part it doesn't show the "Empty" comment... I don't understand why... as far as I can tell the code is fine... Code: [Select] <?php //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box3">'; if (!empty($row['Nonconformity']) || !empty($row['Disposition']) || !empty($row['Comments']) || !empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />' . $row['Nonconformity'] . '</div>'; echo '<div id="dis"><span class="b">Disposition: </span><br />' . $row['Disposition'] . '</div>'; echo '<div id="comm"><span class="b">Comments: </span><br />' . $row['Comments'] . '</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />' . $row['CommentsAdditional_Details'] . '</div>';} else if (empty($row['Nonconformity']) || empty($row['Disposition']) || empty($row['Comments']) || empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />Empty</div>'; echo '<div id="dis"><span class="b">Disposition: <br /></span>Empty</div>'; echo '<div id="comm"><span class="b">Comments: <br /></span>Empty</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />Empty</div>';} echo '</div>'; ?> Is jquery/Ajax better than real/raw PHP for form validation ?! What if JavaScript is turned off on the browser?! why after someone refreshing a page on the browser, the variables used to echo error after invalid data is being submitted will return the undefined variables error?! And how to handle form validation including an empty form field, maximum amount of value entered and so on Currently I'm trying to get a registration form to work adding a username and password into a database. That bit I understand and have managed to do aswell as getting the password to hash using the line below: $hashed = password_hash($password, PASSWORD_DEFAULT);
What I'm trying to do now is have the passwords check to see if they are the same, if so the user is able to register, if not they are sent back to the registration page(which was working before I started tampering with the next bit). I also want to checkto see if the username is taken, the following code is what I have so far: <?php session_start(); /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "root", "", "rockinrochester"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $sql= mysql_query("SELECT FROM register (username, password) WHERE username=$username"); if(mysql_num_rows($sql)>=1) { echo"name already exists"; } else { $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $hashed = password_hash($password, PASSWORD_DEFAULT); if($password != $password2) { //checks to see if passwords match, if they don't it redirects person back to registration form header('Location: register.php'); echo "passwords didn't match"; } else { $sql = "INSERT INTO register (username, password) VALUES ( '$username','$hashed')"; // if passwords match inputs them into database } if(mysqli_query($link, $sql)){ header('Location: registered.php'); // if it works relocated person to registered.html } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); // if it fails it prints an error message } // Close connection mysqli_close($link); } ?> <?php session_start(); /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "root", "", "rockinrochester"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $hashed = password_hash($password, PASSWORD_DEFAULT); $sql = mysql_query("SELECT FROM register(username, password, ) WHERE username=$username"); if(mysql_num_rows($sql)>=1) { echo"name already exists"; } else{ if($password != $password2) { //checks to see if passwords match, if they don't it redirects person back to registration form header('Location: register.php'); echo "passwords didn't match"; } else { $sql = "INSERT INTO register (username, password) VALUES ( '$username','$hashed')"; // if passwords match inputs them into database } if(mysqli_query($link, $sql)){ header('Location: registered.php'); // if it works relocated person to registered.html } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); // if it fails it prints an error message } // Close connection mysqli_close($link); } ?> at the minute It's throwing back the following error Quote
Edited April 4, 2019 by dylfs changing code Hi Guys, This is really stumping me here lol i have set my registration page code to email me when a user signs up (once its entered in the database) code: Code: [Select] <?php if (isset($_POST['submitSignUp'])) { // Errors array() $errors = array(); // POST vars $fName = mysql_real_escape_string($_POST['fname']); $lName = mysql_real_escape_string($_POST['lname']); $email = mysql_real_escape_string($_POST['email']); $pass1 = mysql_real_escape_string($_POST['pass1']); $pass2 = mysql_real_escape_string($_POST['pass2']); $cntry = mysql_real_escape_string($_POST['cntry']); // Does passwords match if ($pass1 != $pass2) { $errors[] = "Your passwords don't match."; } // Potential errors // Empty fields if (empty($fName) || empty($lName) || empty($email) || empty($pass1) || empty($pass2)) { $errors[] = "You never filled in all the fields."; } else { // Does user exist? $result = mysql_query("SELECT * FROM `dig_customers` WHERE `email`='$email' LIMIT 1"); if (mysql_num_rows($result) > 0) { $errors[] = "The e-mail address <b>$email</b> has already been registered."; } else { // Empty for now... } } // display errors if any exist if (count($errors) > 0) { print "<div id=\"errorMsg\"><h3>Ooops! There was error(s)</h3><ol>"; foreach($errors as $error) { print "<li>$error</li>"; } print "</ol></div>"; } else { print "<div id=\"okMsg\"><p>All done :) you can now sign in.</p></div>"; // Encrypt the password before insertion $encPass = md5($pass1); // Insert into the database $q = mysql_query("INSERT INTO `dig_customers` (`id`, `password`, `password_unencrypted`, `gender`, `title`, `first_name`, `last_name`, `address`, `city`, `state_county`, `post_zip_code`, `country`, `email`, `home_number`, `mobile_number`, `news_letter`, `special_offers`, `admin_level`, `registered`) VALUES ('', '$encPass', '$pass1', 'NULL', 'NULL', '$fName', '$lName', 'NULL', 'NULL', 'NULL', 'NULL', '$cntry', '$email', 'NULL', 'NULL', 'NULL', 'NULL', 'N', NOW())"); if ($q) { // Alert on signup send_graham_email("User Has Signed Up!"); } } } ?> When i do a test signup on: http://www.digicures.com/sign-up.php everything works great i get an email and the entry is saved in the database, over the paste week or so i have had about 8 emails saying people have signed up but when i check the database there nothing there! i can't understand it, only when the insert query is true should it send me the mail eh? can anyone see any problems with the code at all? cheers guys Graham I'm making a registration form and i want to add a user when i click the registration button, but the user can not already be in the database, i set the user to be unique inside of the database and when i try to add a new user it gives an error message, but instead of that error message i would like to input please enter another user-name or user already exist something like that the error message says duplicate entry 'username' inside of db basically... can someone help me with this ? I'm a bit stumped here and as usual I'm sure it's something simple. I have an object that checks if a user is an admin. It works fine. But it the HTML below it is not getting displayed. Take a look. welcome.php session_start(); $user = new users(); if (!isset($_SESSION['username'], $_SESSION['imadmin']) || $user->is_admin($_SESSION['username'])==0) { header('Location: index.php'); } welcome.php is getting displayed without getting redirected to the index. But there's no HTML, just the URL to welcome.php in the bar. Anyone? Cheers! Can anyone explain how i can create a registration and login page using PHP that doesnt use databases, sessions, or cookies? Is there a tutorial someone can point me to or could anyone tell me the method. Thanks first time php coder Hi Does anyone know any good tutorials for creating a registration page for a website? Thanks in advance. Register.php Code: [Select] <?php $page_title = "Register"; $rank_check = 0; include "header.inc.php"; if (!$remember_day) { $remember_day = "DD"; } if (!$remember_month) { $remember_month = "MM"; } if (!$remember_year) { $remember_year = "YYYY"; } if ($remember_gender == 1) { $rememberFemale = " SELECTED"; } else { $rememberMale = " SELECTED"; } print "$openHTML"; ECHO <<<END <P align="center"><FORM ACTION=$base_url/register.pro.php METHOD=POST> <CENTER><FONT SIZE="-2" COLOR="#FF0000"><B>*</B></FONT><FONT SIZE="-1">Information checked with a red star means that information<br> is required to register here on Music World Anonymous!</FONT> <P><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=450> <TR> <TD COLSPAN=2 BGCOLOR="$topAndBottomBG"> <P><FONT SIZE="-1" COLOR="$topAndBottomText"><B>Account Information:</B></FONT></P> </TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH=130> <P><FONT SIZE="-1"><B>Username: </B></FONT><FONT SIZE="-1" COLOR="#FF0000"><B>*</B></FONT><FONT SIZE="-1"><BR> &#149; 20 Char. Limit<BR> &#149; a-z and 0-9 only!<BR> &#149; </FONT><A HREF="javascript:;" onclick="window.open('check_names.php','checknames',config='height=250,width=250,menubar=no,resizable=yes,directories=no,scrollbars=no,status=yes,toolbar=no'); return false;"><FONT SIZE="-1">See if it's available!</FONT></A></P> </TD> <TD> <P> <INPUT TYPE=text NAME="reg_username" VALUE="$remember_username" SIZE=32 MAXLENGTH=20></P> </TD> </TR> <TR BGCOLOR="$reallyLight"> <TD WIDTH=130> <P><FONT SIZE="-1"><B>Display Name: </B></FONT><FONT SIZE="-1"><BR> &#149; 25 Char. Limit<BR> &#149; Same as username, Add spaces and CaPs!</FONT></P> </TD> <TD> <P> <INPUT TYPE=text NAME="reg_display_name" VALUE="$remember_display_name" SIZE=32 MAXLENGTH=25></P> </TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH=130> <P><FONT SIZE="-1"><B>Password: </B></FONT><FONT SIZE="-1" COLOR="#FF0000"><B>*</B></FONT><FONT SIZE="-1"><BR> &#149; CaSe SenSitIVe!</FONT></P> </TD> <TD> <P> <INPUT TYPE=password NAME="reg_pass1" SIZE=32></P> </TD> </TR> <TR BGCOLOR="$reallyLight"> <TD WIDTH=130> <P><FONT SIZE="-1"><B>Confirm Password: </B></FONT><FONT SIZE="-1" COLOR="#FF0000"><B>*</B></FONT><FONT SIZE="-1"><BR> &#149; CaSe SenSitIVe!<BR> &#149; Must match previous password!</FONT></P> </TD> <TD> <P> <INPUT TYPE=password NAME="reg_pass2" SIZE=32></P> </TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH=130 HEIGHT=20> <P><FONT SIZE="-1"><B>Name: </B></FONT></P> </TD> <TD> <P> <INPUT TYPE=text NAME="reg_full_name" VALUE="$remember_name" SIZE=32></P> </TD> </TR> <TR BGCOLOR="$reallyLight"> <TD WIDTH=130 HEIGHT=20> <P><FONT SIZE="-1"><B>Email Address: </B></FONT><FONT SIZE="-1" COLOR="#FF0000"><B>*</B></FONT></P> </TD> <TD> <P> <INPUT TYPE=text NAME="reg_email" VALUE="$remember_email" SIZE=32></P> </TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH=130 HEIGHT=20> <P><FONT SIZE="-1"><B>Location:</B></FONT></P> </TD> <TD> <P> <INPUT TYPE=text NAME="reg_location" VALUE="$remember_location" SIZE=32></P> </TD> </TR> <TR BGCOLOR="$reallyLight"> <TD WIDTH=130 HEIGHT=20> <P><FONT SIZE="-1"><B>Birthday: </B></FONT></P> </TD> <TD> <P> <INPUT TYPE=text NAME="reg_month" VALUE="$remember_month" SIZE=4> <INPUT TYPE=text NAME="reg_day" VALUE="$remember_day" SIZE=4> <INPUT TYPE=text NAME="reg_year" VALUE="$remember_year" SIZE=7> </P> </TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH=130> <P><FONT SIZE="-1"><B>Gender: </B></FONT></P> </TD> <TD> <P> <SELECT NAME=reg_gender> <OPTION value=1$rememberFemale>Female</OPTION> <OPTION value=2$rememberMale>Male</OPTION> </SELECT></P> </TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH=130> <P><FONT SIZE="-1"><B>Bio:</B></FONT></P> </TD> <TD> <P> <TEXTAREA NAME=reg_bio ROWS=6 COLS=34 WRAP=virtual>$remember_bio</TEXTAREA></P> </TD> </TR> </TABLE> </P> <P><FONT SIZE="-1">All information is provided here is safe. No personal information will ever be sold for any reason. Read our </FONT><A HREF="privacy.php"><FONT SIZE="-1">Privacy Policy</FONT></A><FONT SIZE="-1"> for more information.</FONT></P> <P><FONT SIZE="-1">By registering an account here you agree to all of our </FONT><A HREF="tos.php"><FONT SIZE="-1">Terms and Conditions</FONT></A><FONT SIZE="-1">!</FONT></P> <P><FONT SIZE="-1"><INPUT TYPE=submit NAME=Submit VALUE="Register! :)"></FONT></CENTER> </FORM></P> END; print "$closeHTML"; ?> Register.pro.php Code: [Select] <?php include "config.inc.php"; $rememberInfo = "?remember_username=$remember_username&remember_display_name=$reg_display_name&remember_name=$reg_full_name&remember_email=$reg_email&remember_location=$reg_location&remember_month=$reg_month&remember_day=$reg_day&remember_year=$reg_year&remember_bio=$reg_bio"; if ((!$remember_username) OR (!$reg_pass1) OR (!$reg_pass2) OR (!$reg_email)) { die(header(error("register.php$rememberInfo","Please fill in all required information."))); } $reg_username = strtolower($reg_username); $check_username = fetch("SELECT id FROM members2 WHERE username = '$reg_username'"); if ($check_username[id]) { die(header(error("register.php$rememberInfo","The username you have selected alredy exists. Please try again."))); } if ($reg_pass1 != $reg_pass2) { die(header(error("register.php$rememberInfo","Your passwords did not match. Passwords ARE CaSe SenSitIVe."))); } if (!$reg_display_name) { $reg_display_name = $reg_username; } $newDisplay = strtolower(ereg_replace(" ","","$reg_display_name")); if ($newDisplay != $reg_username) { die(header(error("register.php$rememberInfo","Your display name must contain the exact same letters as your username with the exception of spaces and capitals."))); } $mwa22pass = md5($reg_pass1); if ( ($this_year-$reg_year >= 13) OR (($this_year-$reg_year == 12) AND ($this_month-$reg_month >= 1)) OR (($this_year-$reg_year == 12) AND ($this_month-$reg_month == 0) AND ($today-$reg_day >= 0))) { $rank = 3; } else { $rank = 2; } if (($reg_month < 1) OR ($reg_month > 12) OR ($reg_day < 1) OR ($reg_day > 31) OR ($reg_year < 0) OR ($reg_year > $this_year)) { die(header(error("register.php$rememberInfo","Please choose a VALID bithdate."))); } $reg_username = badwords($reg_username); if (($reg_gender != "1") AND ($reg_gender != "2")) { die(header(error("register.php$rememberInfo","Please choose a VALID gender."))); } $reg_bio = smilies(badwords(strip_tags($reg_bio,"<b><i><u><a><font><img><p><br><body><background>"))); $reg_sig = badwords(strip_tags($reg_sig,"<b><i><u><a><font>")); if (preg_match('/^[a-z0-9_]*$/UD',$reg_username)) { $insertMemberID = mysql_insert_id(); mysql_query("INSERT INTO members2 (username,password,display_name,rank,email,name,birthday,account_made,location,gender,bio) VALUES ('$reg_username','$mwa22pass','$reg_display_name','$rank','$reg_email','$reg_full_name','$reg_month-$reg_day-$reg_year','$timestamp','$reg_location','$reg_gender','$reg_bio'')"); } else { die(header(error("register.php$rememberInfo","Your username can only contain a-z, 0-9 and underscores. Please try again."))); } setcookie("54865421545_mwauser",$reg_username,time()+2678400); setcookie("14182525mwapass_mwauser",$mwa22pass,time()+2678400); die(header(error("index.php$rememberInfo","Thank you for registering. :D"))); ?> It always says that the required info is not filled in - when it actually is. So then noone can make an account because of it. Required fields a name, email, password, password2 (the one you confirm). If you need more info feel free to ask. Hello, I am currently coding a site from scratch. I know i can use templates and everything else but i want the experience. The HTML I've had down for years but it seems PHP is getting a little elusive for me. I'm trying to create a registration form and when i test my site i keep getting parse errors and syntax errors... mainly regarding the use of {} and if/else. Any help would be appreciated. Most of the code is still incomplete, I have to go back and fill in some areas I've left blank for now, but i have commented using // Where the browser is kicking back my errors.
- “Any sufficiently advanced technology is indistinguishable from magic” (Arthur C. Clark, 1962)
<?php $con = Mysqli_connect("'', '', ''"); if (Mysqli_connect_errno()) { echo "Failed to connect to DB. Please check your connection info." . Mysqli_connect_errno; // Only if there is an error. } //Declaring Variable for Registration form $fname = ""; $lname = ""; $em = ""; $emc = ""; $pass = ""; $passc = ""; $date = ""; $error_array = ""; if (insert($_POST['register_button'])) { // To handle the registration form // First Name Values $fname = strip_tags($_POST['reg_fname']); $fname = str_replace(' ', '', $fname); $fname = ucfirst(strtolower($fname)); // Last Name Values $lname = strip_tags($_POST['reg_lname']); $lname = str_replace(' ', '', $lname); $lname = ucfirst(strtolower($lname)); // Registration Email Values $em = strip_tags($_POST['reg_email']); $em = str_replace(' ', '', $em); // Confirm Registration Email Values $emc = strip_tags($_POST['reg_emailc']); $emc = str_replace(' ', '', $emc); // Registrsation Password Values $pass = strip_tags($_POST['reg_pass']); // Registration Password Confirmation Values $passc = strip_tags($_POST['reg_passc']); // Registration Date Values $date = date("m-d-Y"); // Here is where the browser keeps kicking back parse errors if ($em == $emc) { } else { echo "Email and Confirmation Email must match"; } if (filter_var($em, FILTER_VALIDATE_EMAIL)) { $em = filter_var($em, FILTER_VALIDATE_EMAIL) } else { echo "Invlaid Format"; } ?>
Any body please, Why my registration form page stoped working, don't feed the dbase any more, I'm the only one with access to make changes but I did not make any changes, just stoped out of no where, any ideas? Hi, php newbie here, web developer newbie too! Some time ago I did a website which included a course registration form which someone else created for me in php. This worked fine and I amended the original to work on another website. I am currently updating this second website and the php has stopped working, and I am no longer in contact with the original developer of the code. The form is at: http://www.bisntechnologies.com/register.htm, and the php is: <?php /* ------- Stuff You Can Change --------- */ $recipient = 'registration@bisntechnologies.com'; $redirect = 'confirmation.php'; /* -------------------------------------- */ $name = $HTTP_POST_VARS['name']; $company = $HTTP_POST_VARS['company']; $position = $HTTP_POST_VARS['position']; $telephone = $HTTP_POST_VARS['telephone']; $email = $HTTP_POST_VARS['email']; $interest = $HTTP_POST_VARS['interest']; $clientip = $_SERVER['REMOTE_ADDR']; $msg = "Name: $name\nCompany: $company\nPosition: $position\nTelephone: $telephone\nE-mail: $email\nInterest: $interest\n\nIP Address: $clientip"; $replymsg = "<html><body style=\"font-family: Trebuchet MS; font-size: 13px\"><p>Dear $name,</p><p>Thank you for registering.</p><p><a href=\"http://www.bisntechnologies.com\"><img border=0 src=\"http://www.bisntechnologies.com/images/NewLogo.jpg\" alt=\"BiSN Technologies Ltd\"></a></p></body></html>"; if (mail($email,'Registration',$replymsg,"MIME-Version: 1.0\r\nContent-type: text/html;charset=iso-8859-1\r\nFrom: registration@bisntechnologies.com")) { mail($recipient,'Registration Confirmation',$msg,"From: $email"); include($redirect); } else { echo "<h4>\"$email\" is an invalid e-mail address. Please click the browser's Back button.</h4>"; } ?> Putting in valid information gives the error: "" is an invalid e-mail address. Please click the browser's Back button." which it didn't used to do. I expect it is a very simple mistake but I cannot trace it. Any help to pinpoint the problem greatly appreciated. I need an Event Registration Script that allows for payment with Paypal & saves form details and Paypal transaction ID to my MySQL DB After the payment has been finalized. I want to have ppl be able to register for camp, and with that choose if they want to preorder the new camp DVD, order last camps DVD, order both DVD's or neither DVD. I am not incredible gifted with PHP since I am new so please be gentle. What do you recommend? I would like to learn a little from this process instead of buying a completed script. Thanks below is the code for a registration form. It "works",I mean that the insert query is being performed, some error messages appear. the problem is, i don't understand how "root" is being automatically sent to the database as a username. when logging into phpmyadmin, the username root appears because it is on autofill. but, i don't get why it's filling the registration form with root. i don't see "root" entered on the form, but, after registering, it says "Congratulations root!". If i leave the form blank, i don't get the error message for blank username either. i've just started learning php,so i guess something might be wrong with the code. any help, please? Code: [Select] <html> <head> <link rel="stylesheet" type="text/css" href="reset.css" media="screen" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> <title>Register</title> </head> <body> <div id="layout_wrapper"> <div id="layout_container"> <div id="layout_content"> <div id="site_title"> <h1><a href="home.html">WEBSITE</a></h1> <h2>WEBSITE DESCRI</h2> </div> <div id="header_image"></div> <div class="clearer"> </div> </div> <div id="main"> <div class="post"> <div class="post_top"> <div class="post_title"><h2>REGISTER</h2></div> </div> <div class="post_body"> <?php $error_stat=0; $errorMsg=''; if (isset ($_POST['submit'])){ $username = $_POST['username']; $gender = preg_replace('#[^a-z]#i', '', $_POST['gender']); $b_m = preg_replace('#[^0-9]#i', '', $_POST['birth_month']); $b_d = preg_replace('#[^0-9]#i', '', $_POST['birth_day']); $b_y = preg_replace('#[^0-9]#i', '', $_POST['birth_year']); $email1 = $_POST['email1']; $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $email1 = stripslashes($email1); $pass1 = stripslashes($pass1); $email2 = stripslashes($email2); $pass2 = stripslashes($pass2); $email1 = strip_tags($email1); $pass1 = strip_tags($pass1); $email2 = strip_tags($email2); $pass2 = strip_tags($pass2); include_once "../scripts/connect_to_mysql.php"; $emailCHecker = mysql_real_escape_string($email1); $emailCHecker = str_replace("`", "", $emailCHecker); $sql_uname_check = mysql_query("SELECT user_name FROM tbl_user WHERE user_name='$username'"); $uname_check = mysql_num_rows($sql_uname_check); $sql_email_check = mysql_query("SELECT email FROM tbl_user WHERE email='$emailCHecker'"); $email_check = mysql_num_rows($sql_email_check); if ((!$username) || (!$gender) || (!$b_m) || (!$b_d) || (!$b_y) || (!$email1) || (!$pass1) || (!$pass2)) { $error_stat=1; $errorMsg = 'ERROR: You did not submit the following required information:<br /><br />'; if(!$username){ $errorMsg .= ' * User Name<br />'; } if(!$gender){ $errorMsg .= ' * Sex <br />'; } if(!$b_m){ $errorMsg .= ' * Birth Month<br />'; } if(!$b_d){ $errorMsg .= ' * Birth Day<br />'; } if(!$b_y){ $errorMsg .= ' * Birth year<br />'; } if(!$email1){ $errorMsg .= ' * Email Address<br />'; } if(!$pass1){ $errorMsg .= ' * Login Password<br />'; } if(!$pass2){ $errorMsg .= ' * Confirm Login Password<br />'; } } else if ($pass1 != $pass2) { $errorMsg = 'ERROR: Your Password fields below do not match<br />'; } else if (strlen($username) < 4) { $errorMsg = "<u>ERROR:</u><br />Your User Name is too short. 4 - 20 characters please.<br />"; } else if (strlen($username) > 20) { $errorMsg = "<u>ERROR:</u><br />Your User Name is too long. 4 - 20 characters please.<br />"; } else if ($uname_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside of our system. Please try another.<br />"; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside of our system. Please use another.<br />"; } else { $email1 = mysql_real_escape_string($email1); $pass1 = mysql_real_escape_string($pass1); $full_birthday = "$b_y-$b_m-$b_d"; $sql = mysql_query("INSERT INTO tbl_user (user_name, sex, dob, date_joined,email, password) VALUES('$username','$gender','$full_birthday', now(),'$email1', '$pass1')") or die (mysql_error()); $id = mysql_insert_id(); echo "<h2>Registration Successful!</h2>"; echo "<p>Congratulations <b>$username</b>, your registration was successful. Your account has now been created with the following details:</p>"; echo "<p><b>Username:</b> $username</p>"; echo "<p><b>Password:</b> $pass1</p>"; echo "<p><b>Sex:</b> $gender</p>"; echo "<p><b>Email:</b> $email1</p>"; echo "<p><b>DOB:</b> $full_birthday</p>"; echo "<p>You may now login.</p>"; } // Close else after duplication checks } if (!isset($_POST['submit']) || $error_stat==1) { ?> <?php echo $errorMsg;?> <form method="POST" action=""> <table> <tr> <td width="114" bgcolor="#FFFFFF">User Name: *</span></td> <td width="452" bgcolor="#FFFFFF"><input name="username" type="text" id="username " size="32" maxlength="20" /> <span id="nameresponse">Alphanumeric Characters Only</span></td> </tr> <tr> <td bgcolor="#EFEFEF">Sex:*</span></td> <td bgcolor="#EFEFEF"><label> <input name="gender" type="radio" id="gender" value="m" checked="checked" />Male <input type="radio" name="gender" id="gender" value="f" />Female </label></td> </tr> <tr> <td bgcolor="#FFFFFF">Date of Birth:*</span></td> <td bgcolor="#FFFFFF"> <select name="birth_month" id="birth_month"> <option value="01">January</option> <option value="02">February</option> <option value="03">March</option> <option value="04">April</option> <option value="05">May</option> <option value="06">June</option> <option value="07">July</option> <option value="08">August</option> <option value="09">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="birth_day" id="birth_day"> <option value="01">1</option> <option value="02">2</option> <option value="03">3</option> <option value="04">4</option> <option value="05">5</option> <option value="06">6</option> <option value="07">7</option> <option value="08">8</option> <option value="09">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="birth_year" id="birth_year"> <option value="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select> </td> </tr> <tr> <td bgcolor="#EFEFEF">Email Address:*</span></td> <td bgcolor="#EFEFEF"><input name="email1" type="text" id="email1" size="32" maxlength="48" /></td> </tr> <tr> <td bgcolor="#FFFFFF">Create Password:*</span></td> <td bgcolor="#FFFFFF"><input name="pass1" type="password" id="pass1" size="32" maxlength="16" /> <span>Alphanumeric Characters Only</span></td> </tr> <tr> <td bgcolor="#EFEFEF">Confirm Password: *</span></td> <td bgcolor="#EFEFEF"><input name="pass2" type="password" id="pass2" size="32" maxlength="16" /> <span>Alphanumeric Characters Only</span></td> </tr> <tr> <td><input type="submit" name="submit" value="Sign Up!" /></td> </tr> </table> </form> <?php } ?> </div> <div id="footer"> <div class="left">© 2011</div> <div class="right"><a href="#">....</a><a href="#">....</a></div> <div class="clearer"> </div> </div> </div> </div> </div> </body> </html> Need help with some whiles, etc., and .php page refreshes. $num; Comes from mysql_num_rows from a database table's regular 'select'. And gets the row id numbers for every row that the id numbers are listed in order. $totalrows comes from another select but is select * instead. And pulls the total rows in the whole table instead there are 49 rows in the whole table. I'm trying to get the page to show 5 table rows at a time like the following, but then when the page is still open on next page refresh to show the next 5 rows and continue that way. This following: Quote PHP Code: <?php $i=$num; if ($num == 5); {echo "The number is " . $num . "<br />";} do {$i = $i + 5; echo "The number is " . $i . "<br />"; } while ($i<$totalrows); ?> Brings up these results: The row number is 10 The row number is 15 The row number is 20 The row number is 25 The row number is 30 The row number is 35 The row number is 40 The row number is 45 The row number is 50 Shows all these on the page at the same time. I'm trying to get these to only show the 5 rows after every page refresh instead. Please let me know how to do that, and whether it can be done without any cookies. I don't know if there is a better way to show the first 5 separate like I have it. Thank you very much for your help. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=350931.0 ok well my registration page is supposed to send out an email so the user can activate his or her account , but it will not send! i am using xampp for my local webhost and my php.ini settings are [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = relay.jangosmtp.net ; http://php.net/smtp-port smtp_port = 587 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = activate.social@gmail.com sendmail_path="\"C:\xampp\sendmail\sendmail.exe\"-t and my sendmail.ini is account Gmail tls on tls_certcheck off host relay.jangosmtp.net from activate.social@gmail.com auth on user activate.social@gmail.com password mypassword port 587 account default : Gmail and now here is my php script that sends the mail but it wont send , the reason i put those .ini files in here is because that is what xampp uses to send mail. here is the php script Code: [Select] <?php $to = "$email1";// which is established further up on the script which is to big! $from = 'activate.social@gmail.com'; // same email used in php.ini and sendmail.ini but wont send $subject = 'Complete Your ' . $dyn_www . ' Registration'; //Begin HTML Email Message $message = "Hi $username, Complete this step to activate your login identity at $dyn_www Click the line below to activate when ready http://$dyn_www/activation.php?id=$id&sequence=$db_password If the URL above is not an active link, please copy and paste it into your browser address bar Login after successful activation using your: E-mail Address: $email1 Password: $pass1 See you on the site!"; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text\r\n"; mail($to, $subject, $message, $headers); // supposed to send but wont ?> Hi I'm new here, also I'm new in php. What I need to do is to write registration form with drop down menu. Actually, I need to have drop down menu which would write data into database when someone fill registration form. Also I need when someone choose one of the city name in drop down menu, to display certain image in specific php page. Can anyone help me. Here is my code for registration form : register.php <?PHP //Database Information $dbhost = ""; $dbname = ""; $dbuser = ""; $dbpass = ""; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $name = $_POST['name']; $email = $_POST['email']; $username = $_POST['username']; $password = md5($_POST['password']); $grad = $_POST['grad']; // lets check to see if the username already exists $checkuser = mysql_query("SELECT username FROM users WHERE username='$username'"); $username_exist = mysql_num_rows($checkuser); if($username_exist > 0){ echo "I'm sorry but the username you specified has already been taken. Please pick another one."; unset($username); include 'register.html'; exit(); } $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'"); $email_exist = mysql_num_rows($checkemail); if($email_exist > 0){ echo "Email koji ste izabrali vec postoji."; unset($email); include 'register.html'; exit(); } $checkname = mysql_query("SELECT name FROM users WHERE name='$name'"); $name_exist = mysql_num_rows($checkname); if($name_exist > 0){ echo "Ime koje ste izabrali vec postoji."; unset($name); include 'register.html'; exit(); } // lf no errors present with the username // use a query to insert the data into the database. $query = "INSERT INTO users (name, email, username, password, grad) VALUES('$name', '$email', '$username', '$password','$grad')"; mysql_query($query) or die(mysql_error()); mysql_close(); if(empty($name) || empty($email) || empty($username)) { echo "Nisu uneseni svi podaci."; } /*else if(empty(($password))) //ovaj uslov ne prolazi !!! { echo "Niste uneli lozinku."; }*/ else { echo "Uspesno ste se registrovali"; } ?> and for form : register.html <form name="login" method="post" action="register.php"> <table border="0" width="225" align="center"> <tr> <td width="219" bgcolor="#ff6600"> <p align="center"><font color="white"><span style="font-size:14pt;"><b>Registration</b></span></font></p> </td> </tr> <tr> <td width="555"> <table border="0" width="555" align="center"> <tr> <td width="116"><span style="font-size:12pt;">Name:</span></td> <td width="156"><input type="text" name="name" maxlength="100"></td> <td width="200"><p align="left"><span style="font-size:11pt;"><i>*Ukucajte vase puno ime i prezime*</i></span></p></td> </tr> <tr> <td width="116"><span style="font-size:12pt;">Email:</span></td> <td width="156"><input type="text" name="email" maxlength="100"></td><br/> </tr> <tr> <td width="116"><span style="font-size:12pt;">Username:</span></td> <td width="156"><input type="text" name="username"></td><br/> </tr> <tr> <td width="116"><span style="font-size:12pt;">Password:</span></td> <td width="156"><input type="password" name="password"></td><br/> </tr> <tr> <td width="116"> </td> <td width="156"> <p align="right"><input type="submit" name="submit" value="Submit"></p> </td> </tr> <tr> <td> <select name = "dropdown" value="options"> <option value "register.php">Izaberi grad</option> <option value = "Beograd">Beograd</option> <option value = "Nis">Nis</option> <option value = "Novi Sad">Novi Sad</option> </select> </td> </tr> </table> </td> </tr> <tr> <td width="219" bgcolor="#ff6600"> </td> </tr> </table> </form> Hello, iv got a code that validates form fields: ////////////////////duomenys is regform.php $username = $_POST['regname']; $email= $_POST['regemail']; $password1 = $_POST['regpass1']; $password2 = $_POST['regpass2']; /////////////////////////////////////////// ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); $result = pg_query('SELECT 1 FROM duom WHERE LOWER(name)=\''.strtolower(pg_escape_string($username)).'\'')or exit(pg_last_error()); if(isset($_POST['regsubmit'])){ ////////////////////////////////////tikrina ar viskas uzpildyta if($username !="" && $email !="" && $password1 !="" && $password2 !="" && $password1 == $password2) { /////////////////////////////////////////////////////////////// if (pg_num_rows($result)) { exit('Toks vartotojas jau egzistuoja, pasirinkite kita vartotojo varda'); } else ///////////////////ideda duomenys is regform.php i duomenu baze $insert = "INSERT into duom(name, email, pass) VALUES('".$username."','".$email."','".$password1."')"; pg_query($insert); echo "Registracija pavyko!"; /////////////////////////////////////////////////////////////// } else echo "Blogai uzpildyti domenys!"; } everything is working but i need to add 1 more thing to this - to see if email already exists in the databse. I did it for username but idk how to add the same code for email. Heres the code to check if username already exists: ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); $result = pg_query('SELECT 1 FROM duom WHERE LOWER(name)=\''.strtolower(pg_escape_string($username)).'\'')or exit(pg_last_error()); if (pg_num_rows($result)) { exit('Username already exists); thanks in advance |