beav33 Posted July 25, 2006 Share Posted July 25, 2006 This is some of the code below that dreamweaver places for a registration record set. Now I want to validate some things like making sure the passwords match up and email, so on. I can't figure out how to change my code to identify it. My code is below dreamweavers, please help.// *** Redirect if username exists$MM_flag="MM_insert";if (isset($_POST[$MM_flag])) { $MM_dupKeyRedirect="takenusername.php"; $loginUsername = $_POST['username']; $LoginRS__query = sprintf("SELECT username FROM register WHERE username=%s", GetSQLValueString($loginUsername, "text")); mysql_select_db($database_db_connect, $db_connect); $LoginRS=mysql_query($LoginRS__query, $db_connect) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); //if there is a row in the database, the username was found - can not add the requested username if($loginFoundUser){ $MM_qsChar = "?"; //append the username to the redirect page if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&"; $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; header ("Location: $MM_dupKeyRedirect"); exit; }}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO register (username, password, email, companyname, firstname, lastname, phone) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['username'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['companyname'], "text"), GetSQLValueString($_POST['firstname'], "text"), GetSQLValueString($_POST['lastname'], "text"), GetSQLValueString($_POST['phone'], "text"));Dreamweaver's way to check username and varibles.My code //create short variable names $email=$_POST['email']; $username=$_POST['username']; $password=$_POST['password']; $password2=$_POST['password2']; $companyname=$_POST['companyname']; $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $phone=$_POST['phone'];Then on down the validation // passwords not the same if ($password != $password2) { throw new Exception('The passwords you entered do not match - please go back' .' and try again.');Just need to change it up a bit to work with dreamweaver's code. BUT HOW?Thank you, beav33 Link to comment https://forums.phpfreaks.com/topic/15635-form-validation/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.