zelllibin Posted August 15, 2008 Share Posted August 15, 2008 HI.. please help me.. i am new on php... <?php session_start(); include "include/mysql_connect.php"; include "include/redirect.php"; $username = $_POST['_username']; $fullname = $_POST ['_fullname']; $email = $_POST['_emailaddress']; $password = $_POST['_password']; if (get_magic_quotes_gpc() ) { $username = stripslahes($username); $fullname = stripslahes($fullname); $email = stripslahes($email); } $error_msg=array(); if($username=="") { $error_msg[]="please enter your username"; } if ($fullname=="") { $error_msg[]="please enter your full name"; } if ($email=="") { $error_msg[]"please enter your email address"; } if ($password=="") { $error_msg[]="please enter your password"; } $query_username = "SELECT `id` FROM members WHERE `username`='$username' "; $exists = query_to_array($query_username); //print_r($exists); if ($exists != ''){ $_SESSION['err_msg'] = "Please try another username"; do_redirect('register.php'); }else{ $fullname = $_POST['_fullname']; $email = $_POST['_emailaddress']; $password = $_POST['_password']; $query_new_user = "INSERT INTO members (`username`, `password`, `email`, `fullname`) VALUES ('$username','$password','$email','$fullname')"; query($query_new_user); $profile = query_to_array("SELECT `id`, `fullname`, `email` FROM members WHERE `username`='$username'"); $_SESSION["u_id"]= $profile["id"]; $_SESSION["u_fullname"]= $profile["fullname"]; $_SESSION["u_email"]= $profile["email"]; $_SESSION["username"]= $username; do_redirect('index.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/119815-help-with-this-code/ Share on other sites More sharing options...
ajclarkson Posted August 15, 2008 Share Posted August 15, 2008 Please state your problem. Providing your code and asking for help is not helpful Link to comment https://forums.phpfreaks.com/topic/119815-help-with-this-code/#findComment-617273 Share on other sites More sharing options...
Nandini Posted August 15, 2008 Share Posted August 15, 2008 What is ur question Mr. zelllibin ? Link to comment https://forums.phpfreaks.com/topic/119815-help-with-this-code/#findComment-617283 Share on other sites More sharing options...
zelllibin Posted August 16, 2008 Author Share Posted August 16, 2008 this code don't seems working for me.. Link to comment https://forums.phpfreaks.com/topic/119815-help-with-this-code/#findComment-617851 Share on other sites More sharing options...
Nandini Posted August 18, 2008 Share Posted August 18, 2008 I dont know exactly what u want to do. But i have a little idea after go through ur code. use the following code <? session_start(); include "include/mysql_connect.php"; include "include/redirect.php"; extract($_POST); $error_colour = "red"; // Must use HTML compatible colour $lang_error = "<center>The following errors were found:</center>"; $lang_user = "<ul style='list-style-position:inside;'><li>Enter user name</li></ul>"; $lang_userexist = "<ul style='list-style-position:inside;'><li>user name already taken</li></ul>"; $lang_fullname = "<ul style='list-style-position:inside;'><li>Enter full name</li></ul>"; $lang_password = "<ul style='list-style-position:inside;'><li>Enter password</li></ul>"; $lang_email = "<ul style='list-style-position:inside;'><li>Enter email</li></ul>"; $query_username = mysql_query("SELECT * FROM members WHERE username='".$_POST['_username']."' "); if (empty ($_POST['_fullname'])) { $error = "1"; $info_error .= "".$lang_fullname . ""; } elseif (empty ($_POST['_password'])) { $error = "1"; $info_error .= "".$lang_password . ""; } elseif (empty ($_POST['_username'])) { $error = "1"; $info_error .= "".$lang_user . ""; } elseif (mysql_num_rows($query_username)>0) { $error = "1"; $info_error .= "".$lang_userexist . ""; echo '<META http-equiv="refresh" content="2;URL=register.php">'; } elseif (empty ($_POST['_emailaddress'])) { $error = "1"; $info_error .= "".$lang_email . ""; } if($error == "1") { $info_notice = "<span style=\"color: " . $error_colour . "; font-weight: bold;\">" . $lang_error . "</span><br>"; if (empty ($submit)) //////here submit means ur form submit button name { $info_error = ""; $info_notice = $lang_notice; } ////////here ur html form <tr><td colspan="2" align="left"><? echo "<span style=\"color:red;\">".$info_error."</span>"; ?></td></tr> (first line in table within form) ////end form } else{ //////ur database like insertion operations } ?> Link to comment https://forums.phpfreaks.com/topic/119815-help-with-this-code/#findComment-618935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.