Jump to content

Recommended Posts

I'm trying to make:

 

Create User.

Verify(Make sure its not a copy of the same email, etc..).

Save user to database.

Allow user to login.

 

Using Heredoc and making it one .php is logic while another .php that's included is display/messages. Just really basic, but for some reason I'm having problems.

 

Index:

<html>
<head>
<body>
<a href="create.php">Create Account</a>
<br />
<a href="login.php">Log In</a>
</head>
</body>
</html>

 

create.php

<?php
$here = <<<END
<form action="verify.php" method="post">
   First Name: <input type="text" name="first" /><br />
   Last Name: <input type="text" name="last" /> <br />
   Email: <input type="text" name="email" /> <br />
   Password: <input type="password" name="pass" /><br />
   <input type="submit" value="Submit />
</form>

END;
echo $here
?>

<?php?>

 

verify.php

<?php
include 'verified.php';
   $connection = mysql_connect("localhost", "root", "********");
   if (!$connection) {
      die("Database connection failed: " . mysql_error());
   }
   
   $db_select = mysql_select_db("test", $connection);
   if (!$db_select) {
      die("Database selection failed: " . mysql_error());
   }
   $result = mysql_query("SELECT * FROM users", $connection);
   if (!$result) {
      die("Database query failed: " . mysql_error());
   }
$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$query = "INSERT INTO users (id, first, last, email, pass)
         VALUES (NULL, '{$first}', '{$last}', '{$email}', '{$pass}')";
$create = mysql_query(addslashes($query))
         
              while ($row = mysql_fetch_array($result)) {
               if($row["email"] == $email) {
                    echo "Email in use.";
         } else { if($create) {
            echo "Success!!"; }
         }
      }

mysql_close($connection);
?>

 

and I'm stuck because it won't insert the data into the database. Can anyone help me?

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.