Jump to content

Can anyone code my register page like this code?


Recommended Posts

Can you's code this register page like this

 

I want it coded like this but this is the login page

 

<?php
  session_start();//At the start!
  include "dbConfig.php";

  $error = '';
  if($_SERVER['REQUEST_METHOD'] == 'POST')
  {
    if(!empty($_POST["username"]) && !empty($_POST["password"]))
    {
      // Create query
      $q = "SELECT * FROM `dbUsers` "
          ."WHERE `username`='".mysql_real_escape_string($_POST["username"])."' "
          ."AND `password`=PASSWORD('".mysql_real_escape_string($_POST["password"])."') "
          ."LIMIT 1";
      // Run query
      $r = mysql_query($q);
      if ( $obj = @mysql_fetch_object($r) )
      {
        // Login good, create session variables
        $_SESSION["valid_id"] = $obj->id;
        $_SESSION["valid_user"] = $_POST["username"];
        $_SESSION["valid_time"] = time();

        // Redirect to member page
        header("Location: home.php");
        exit;
      }else
        $error = "Sorry, You have enterd a wrong Username or Paswword please try again and be more carefull with your spelling!";
    }else
      $error = "You need to provide a username and password.";
  }
?>
<html>
  <head>
    <title>Welcome To UltimateRavers.Net, Your Ultimate Online Raving Destiny!</title>
    <style type="text/css">
@import "stylesheet.css";
    </style>
  </head>
  <body bgcolor="#666666">
    <center>
      <font size="2" face="verdana" color="#3d3d3d">
        <?php echo $error; ?>
        <form method="POST">
          Username<br /><input name="username" size="15"><br />
          Password<br /><input type="password" name="password" size="15"><br />
          <input type="submit" value="Login">
        </form>
      </font>
      <a href="register.php">Click Here To Register!</a>
    </center>
  </body>
</html>

 

 

this is my register.php code:

 

<?php

// dbConfig.php is a file that contains your
// database connection information. This
// tutorial assumes a connection is made from
// this existing file.
include ("dbConfig.php");


//Input vaildation and the dbase code
if ( $_GET["op"] == "reg" )
{
$bInputFlag = false;
foreach ( $_POST as $field )
  {
  if ($field == "")
   {
   $bInputFlag = false;
   }
  else
   {
   $bInputFlag = true;
   }
  }
// If we had problems with the input, exit with error
if ($bInputFlag == false)
  {
  die( "Problem with your registration info. "
   ."Please go back and try again.");
  }

// Fields are clear, add user to database
//  Setup query
$q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
  ."VALUES ('".$_POST["username"]."', "
  ."PASSWORD('".$_POST["password"]."'), "
  ."'".$_POST["email"]."')";
//  Run query
$r = mysql_query($q);

// Make sure query inserted user successfully
if ( !mysql_insert_id() )
  {
  die("Error: User not added to database.");
  }
else
  {
  // Redirect to thank you page.
  Header("Location: register.php?op=thanks");
  }
} // end if


//The thank you page
elseif ( $_GET["op"] == "thanks" )
{
echo "<h2>Thanks for registering!</h2>";
}

//The web form for input ability
else
{
echo "<form action=\"?op=reg\" method=\"POST\">\n";
echo "Username: <input name=\"username\" MAXLENGTH=\"16\"><br />\n";
echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"><br />\n";
echo "<input type=\"submit\">\n";
echo "</form>\n";
}
// EOF
?>

 

I hope you guys no what i mean? Please help me im totaly stuck!

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.