Jump to content

User Registration issue


reddog

Recommended Posts

Hello freaks,

 

I can't seem to figure out why code not working correctly.  Any advise greatly apprechiated.

 

<?php

include_once('connect/mysqlconnect.php');

$user = $_POST['uname'];

$email = $_POST['email'];

$pass1 = $_POST['pass1'];

$pass2 = $_POST['pass2'];

$checkname = mysqli_query("SELECT * FROM users WHERE uname='$user'");

if(isset($_POST['submitted'])){

 

if(mysqli_num_rows($checkname) > 0) {

$errors[] = 'User name not available, please choose different name';

} else {

$u = mysqli_real_escape_string($dbc, $user);

  }

if(!empty($email)) {

$e = mysqli_real_escape_string($dbc, $email);

} else {

$errors[] = 'You did not enter email address!';

}

 

if($pass1 == $_POST['pass2']) {

$p = mysqli_real_escape_string($dbc, trim($pass1));

 

} else{

$errors[] = 'Your password did not match.  Please try again.';

 

}

if(empty($errors)) {

 

  $insert = "INSERT INTO users(uname, email, pass1, register_date) VALUES ('$u','$e',sha1('$p'), NOW(register_date))";

 

  // This execute above statement to INSERT into database

  $r = mysqli_query($dbc, $insert);

  }

  if($r) {

 

  //Print a message:

echo '<h1>Thank you!</h1>

<p>You are now registered.</p><p><br /></p>';

 

  } else {

    echo ',<h1>Server Error</h1>

<p>You could not be registered do to a server error.

We apologize for any inconvience.</p>';

  }

  }

  mysqli_close($dbc);

 

 

        ?>

Link to comment
Share on other sites

are you getting an error? Also please use [ code ] [ /code ] tags

 

<?php
include_once('connect/mysqlconnect.php');
$user = $_POST['uname'];
$email = $_POST['email'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$checkname = mysqli_query("SELECT * FROM users WHERE uname='$user'");
if(isset($_POST['submitted'])){

if(mysqli_num_rows($checkname) > 0) {
   $errors[] = 'User name not available, please choose different name';
      } else {
$u = mysqli_real_escape_string($dbc, $user);
  }
if(!empty($email)) {
$e = mysqli_real_escape_string($dbc, $email);
    } else {
      $errors[] = 'You did not enter email address!';
      }

if($pass1 == $_POST['pass2']) {
       $p = mysqli_real_escape_string($dbc, trim($pass1));
       
      } else{
       $errors[] = 'Your password did not match.  Please try again.';
       
         }
      if(empty($errors)) {
      
      $insert = "INSERT INTO users(uname, email, pass1, register_date) VALUES ('$u','$e',sha1('$p'), NOW(register_date))";
      
      // This execute above statement to INSERT into database
      $r = mysqli_query($dbc, $insert);
      }
      if($r) {
      
         //Print a message:
      echo '<h1>Thank you!</h1>
      <p>You are now registered.</p><p><br /></p>';
      
      } else {
       echo ',<h1>Server Error</h1>
      <p>You could not be registered do to a server error. 
      We apologize for any inconvience.</p>';
     }
     }
     mysqli_close($dbc);

Link to comment
Share on other sites

Here are the warning message I am getting.

 

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\sports\login.php on line 15

 

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\sports\login.php on line 18

 

 

Notice: Undefined variable: r in C:\wamp\www\sports\login.php on line 43

Link to comment
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.