Jump to content

Recommended Posts

This is confusing the hell out of me... sorry for the long code

 

<?php

ini_set ("display_errors", "1");
error_reporting(E_ALL);

if($_POST['submit']) {

  $username = $_POST['username'];
  $password = $_POST['password'];
  $confirmpw = $_POST['confirmpw'];
  $firstname = $_POST['first'];
  $lastname = $_POST['last'];
  $email = $_POST['email'];

  $username = stripslashes($username);
  $password = stripslashes($password);
  $confirmpw = stripslashes($confirmpw);
  $firstname = stripslashes($firstname);
  $lastname = stripslashes($lastname);
  $email = stripslashes($email); 

  if((!$username) || (!$password) || (!$confirmpw) || (!$email)) {
    echo "You didn't fill in all the correct fields. Please try again<BR />";
    echo "Redirecting...";
    exit();
  }

  if($confirmpw != $password) {
    echo "Your passwords did not match. Please try again<BR />";
    echo "Redirecting...";
    exit();
  }

  $emailcheck = mysql_query("SELECT email FROM users WHERE email='$email'");
  $check = mysql_num_rows($emailcheck);

  if($emailcheck > 0) {
    echo "That email is already recorded as been in the database. Please try again<BR />";
    echo "Redirecting...";
    exit();
  }

  $password = md5($password);
  $fullname = $firstname . ' ' . $lastname;

  $query = mysql_query("INSERT INTO users (username, password, fullname, email) VALUES ('$username', '$password', '$fullname', '$email')") or die(mysql_error());

  if(!$query) {
    echo "There was a problem creating your account, please contact an Admin about this problem.";
  } else {
    echo "Your account creation was sucessful. You may now login.";
    echo "Redirecting...";
  }

} else {
?>
  <form method="POST" action="<?php echo $phpself; ?>">
  Username: <input type='text' name='username'><BR />
  Password: <input type='password' name='password'><BR />
  Confirm Password: <input type='password' name='confirmpw'><BR /><BR />
  First Name: <input type='text' name='first'><BR />
  Last Name: <input type='text' name='last'><BR />  
  Email: <input type='text' name='email'><BR />
  <input type='submit' value='submit' name='submit'>
  </form>
<?php
}
?>

 

The error is...

Notice: Undefined index: submit in C:\Inetpub\wwwroot\users\register.php on line 6

Link to comment
https://forums.phpfreaks.com/topic/88691-solved-undefined-index/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.