Jump to content

Registration Script Bug.


drayarms

Recommended Posts

The following script is designed to register users to a site.

 

 

 

 

<?php

 

//address error handling

 

ini_set ('display_errors', 1);

error_reporting (E_ALL & ~E_NOTICE);

 

 

 

// Check if he wants to register:

if (!empty($_POST[username]))

{

// Check if passwords match.

if ($_POST[password] != $_POST[password2])

exit("Error - Passwords don't match. Please go back and try again.");

 

// Assign some variables.

$date = mktime(0,0,0,date("m"),date("d"),date("Y"));

$ip = $_SERVER[REMOTE_ADDR];

 

require_once("config.php");

 

// Register him.

$query = mysql_query("INSERT INTO members

(member_id, username, firstname, lastname, password, register_date, ip)

VALUES (0, '$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[password]','$date','$ip')")

or die ('<p>Could not register user becasue: <b>' .mysql_error().'</b>.</p>');

 

echo "Welcome". ucfirst$_POST[username]. "! You've been successfully reigstered! <br /><br />

        Please login <a href='login.php'><b>here</b></a>.";

 

exit();

}

 

?>

 

<html>

<head>

<title>Register</title>

</head>

 

 

<body>

 

                <?php require('header.html'); ?>

 

 

 

 

 

 

<div id="main" style="background-color: #FFFFFF; height:71%; width:101%; border:0px none none; margin:auto; "> <!--opens the white content area-->

 

 

 

 

 

 

 

              <div id="main_left" style="float:left; height:100%; width:20%; border:0px none none;"> <!--opens main left-->

 

 

 

 

                    <div id="main_left_top" style="float:left; position:relative;bottom:5px;right:5px; height:31.25%; width:93.8%; border:5px solid #c0c0c0; margin:5px;"> <!--opens main left top-->

 

 

                             

 

                    </div> <!-- closes main left top-->

 

 

 

 

                    <div id="main_left_center" style="float:left; background-color: #FFFFFF; height:33%; width:100%; border-color:#a0a0a0;border-style:outset;border-width:1px; margin:auto; "> <!--opens the white content area-->

 

 

 

 

                    </div> <!-- closes main left center-->

 

 

 

 

                    <div id="main_left_bottom" style="float:left; background-color: #FFFFFF; height:33%; width:100%; border-color:#a0a0a0;border-style:outset;border-width:1px; margin:auto; "> <!--opens the white content area-->

 

 

 

 

                    </div> <!-- closes main left bottom-->

 

 

 

 

 

              </div> <!-- closes main left-->

 

 

 

 

 

 

 

              <div id="main_center" class="content_text" style="float:left;  height:98%; width:57%; border:5px solid #c0c0c0;"> <!--opens main center-->

 

 

 

                   

                 

                       

                  <div style=" width:76%; height:40%; position:relative;top:100px; left:50px; ">

         

 

 

                      <form action="register.php" method="post">

<table width="75%" border="1" align="center" cellpadding="3" cellspacing="1">

<tr>

<td width="100%"><h5>Registration</h5></td>

</tr>

<tr>

<td width="100%"><label>Desired Username: <input type="text" name="username" size="25" value="<? echo $_POST[username]; ?>"></label></td>

</tr>

<tr>

<td width="100%"><label>First Name:         <input type="text" name="firstname" size="25" value="<? echo $_POST[firstname]; ?>"></label></td>

</tr>

<tr>

<td width="100%"><label>Last Name:        <input type="text" name="lastname" size="25" value="<? echo $_POST[lastname]; ?>"></label></td>

</tr>

<tr>

<td width="100%"><label>Password:          <input type="password" name="password" size="25" value="<? echo $_POST[password]; ?>"></label></td>

</tr>

<tr>

<td width="100%"><label>Verify Password:     <input type="password" name="password2" size="25" value=""></label></td>

</tr>

<tr>

<td width="100%"><input type="submit" value="Register!"></td>

</tr>

</table>

      </form>

 

 

 

                    </div>

 

 

 

 

 

              </div> <!-- closes main center-->

 

 

 

 

 

 

              <div id="main_right" style="float:left; background-color: #FFFFFF; height:100%; width:20%; border-color:#a0a0a0;border-style:outset;border-width:1px; margin:auto; "> <!--opens the white content area-->

 

 

 

                    <div id="main_right_top" style="float:left; background-color: #FFFFFF; height:33%; width:100%; border-color:#a0a0a0;border-style:outset;border-width:1px; margin:auto; "> <!--opens the white content area-->

 

 

 

 

                    </div> <!-- closes main left top-->

 

 

 

 

                    <div id="main_right_center" style="float:left; background-color: #FFFFFF; height:33%; width:100%; border-color:#a0a0a0;border-style:outset;border-width:1px; margin:auto; "> <!--opens the white content area-->

 

 

 

 

                    </div> <!-- closes main left center-->

 

 

 

 

                    <div id="main_right_bottom" style="float:left; background-color: #FFFFFF; height:33%; width:100%; border-color:#a0a0a0;border-style:outset;border-width:1px; margin:auto; "> <!--opens the white content area-->

 

 

 

 

                    </div> <!-- closes main left bottom-->

 

 

 

              </div> <!-- closes main right-->

 

 

 

 

 

 

 

 

        </div> <!-- closes main-->

 

 

 

 

 

  <?php require('footer.html'); ?>

 

 

 

 

 

         

 

 

</body>

</html>

 

 

 

 

I get the following error message when i try to register members.

 

 

PHP Error Message

 

Warning: mktime() expects parameter 1 to be long, string given in /home/a7522929/public_html/register.php on line 18

 

Free Web Hosting

Error - Couldn't register user.

 

 

Anyone knows what the problem is??? Please help!!!

Link to comment
Share on other sites

Hi, if you are only using mktime() to generate a timestamp for today then you might want to change:

   $date = mktime(0,0,0,date("m"),date("d"),date("Y"));

With:

$date  = time();

 

One of the benefits of this is that the mktime you were using would give u a timestamp for midnight today. time() wil log the exact time the user registered.

 

Another option is to ensure your register_date  datatype in the database is a DATETIME and just use

   $query = mysql_query("INSERT INTO members 
   (member_id, username, firstname, lastname, password, register_date, ip)
   VALUES   (0, '$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[password]',NOW(),'$ip')")

 

 

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.