Jump to content

phpnewbphp

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phpnewbphp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, can anyone help me I'm new to coding and have been having trouble getting my code to insert into the database. I have checked the connection and that works fine but it says you're registered but it dosen't input it into the database. This is the code i have in my script: <?php echo "<h1>Register</h1>"; $submit = $_POST ['submit']; //form data $fullname = strip_tags($_POST ['fullname']); $username = strip_tags($_POST ['username']); $password = strip_tags($_POST ['password']); $repeatpassword = strip_tags($_POST ['repeatpassword']); $date = date ("Y-m-d"); if ($submit) { //check for existance if ($fullname&&$username&&$password&&$repeatpassword) { //check passwords match if ($password==$repeatpassword) { //check char length of username and fullname if (strlen($username)>25||strlen($fullname)>25) { echo "Maximum limit for username and fullname is 25 characters!"; } else { //check password length if (strlen($password)>25||strlen($password)<6) { echo "Your password must be between 6 and 25 characters!"; } else { //register the user //encrypt password $password = md5 ($password); $repeatpassword = md5 ($repeatpassword); //open database $connect = mysql_connect ("localhost","","") or die ("couldn't connect!"); mysql_select_db ("phplogin") or die ("couldn't find db!"); mysql_query ("INSERT INTO users VALUES ('','$fullname','$username','$password','$date')"); die ("You've been registered! <a href='index.php'>Click here</a> to return to login page"); } } } else echo "Your passwords do not match!"; } else echo "Please fill in <b>all</b> fields."; } ?> <html> <form action='register.php' method='POST'> <table> <tr> <td>Your Full name:</td> <td><input type='text' name='fullname' value='<?php echo $fullname ?>'></td> </tr> <tr> <td>Your Username:</td> <td><input type='text' name='username' value='<?php echo $username ?>'></td> </tr> <tr> <td>Your Password:</td> <td><input type='password' name='password'></td> </tr> <tr> <td>Repeat your password:</td> <td><input type='password' name='repeatpassword'></td> </tr> </table> <input type='submit' name='submit' value='Register'> </form> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.