Exc.BluePhoenix Posted March 15, 2008 Share Posted March 15, 2008 Hello, I have a registration script that I want to mod the one below. <?php /*Start session*/ session_start(); /* Array to store validation erros*/ $errmsg_arr = array(); /* Validation flag*/ $errflag = false; /*mysql_conncect, takes 3 arguments. If the var link is succeful, go on, if not die, echo msg.*/ $link = mysql_connect("localhost","username,"password"); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } /*Select db, if unable return error message.*/ $db = mysql_select_db("users"); if(!$db) { die("We are sorry but at this moment we are unable to connect to the Database. Please try again later."); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $firstname = clean($_POST['firstname']); $lastname = clean($_POST['lastname']); $email = clean($_POST['email']); $username = clean($_POST['username']); $password = clean($_POST['password']); $cpassword = clean($_POST['cpassword']); /*I took the validation check so its less code to read*/ //Check for duplicate login ID $query = "SELECT count(*) AS c FROM users WHERE username='$username'"; $result = mysql_query($query); if($result) { $result_array = mysql_fetch_assoc($result); if($result_array['c'] > 0) { $errmsg_arr[] = 'Username already in use'; $errflag = true; } @mysql_free_result($result); } else { die("Query failed"); } //If there are input validations, redirect back to the registration form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: form.php"); exit(); } //Create INSERT query $query = "INSERT INTO users(firstname, lastname, email, username, password) VALUES('$firstname','$lastname', '$email', '$username','".md5($_POST['password'])."')"; $result = mysql_query($query); //Check whether the query was successful or not if($result) { header("location: register-success.php"); exit(); }else { die("Query failed"); } ?> This code registers users. However, I am not really looking for that, what I would like it to are the following: I want it to send the information to a database, but I also want it to echo that information into a different page so that the user can copy and paste all the information that he/she input into the form. I don't want it to register anyone, just echo the information put in the form by the user in a different page. That is what I'm hoping to do, if there is a better script out there to do this or modify please advise me how to get it, (I tried google but I really don't know what to put for the script I'm looking for) Thank you for your time, if there is need for clarification don't hesitate to ask for some, since I might have not explain myself correctly. Quote Link to comment https://forums.phpfreaks.com/topic/96302-modding-a-registration-script/ 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.