Web Analytics Made Easy -
StatCounter error messages aren't working - CodingForum

Announcement

Collapse
No announcement yet.

error messages aren't working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • error messages aren't working

    Hello everyone,

    I've been using $message to post an error if there is one however when I hit registers on the form it returns a blank page.. I'm stuck i've beenusing this method on several other pages and it works fine. Also, if I post errors through header it works but I don't want to post that way since it wont match the look of other pages.

    the URL is www.ericschuppe.com/register.php
    PHP Code:
    <?php 
    session_start
    ();


    include (
    'dbc.php'); 


    if (
    $_POST['Submit'] == 'Register')
    {
     if (
    strlen($_POST['full_name']) < 1)
       {
       
    $message .= '<p>Incorrect email, please enter valid email address.</p>';
        }
       if (
    strlen($_POST['email']) < 5)
       {
       
    $message .= '<p>Incorrect email, please enter valid email address.</p>';
        }
       if (
    strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) )
        {
        
    $messsage .= '<p>Password does not match or empty.</p>';

        }
        if (
    strlen($_POST['user_idnum']) < 4)
            {
            
    $message .= '<p>Incorrect ID number. Please enter a valid ID number.</p>';
            }
        if (
    strcmp(md5($_POST['user_code']),$_SESSION['ckey']))
        {
         
    $message .= '<p>Invalid code entered. Please enter the correct code as shown in the Image.</p>';
              } 
        
    $rs_duplicates mysql_query("SELECT id FROM users WHERE user_email='$_POST[email]'");
        
    $duplicates mysql_num_rows($rs_duplicates);

        if (
    $duplicates 0)
        {
        
    //die ("ERROR: User account already exists.");
        
    $message .= '<p>User account already exists, Try Again.</p>';
        }
        
    $rs_duplicates_id mysql_query("SELECT id FROM users WHERE user_idnum='$_POST[user_idnum]'");
        
    $duplicates_id mysql_num_rows($rs_duplicates_id);

        if (
    $duplicates_id 0)
        {
        
    $message .= '<p>Student ID already exists, Try Again.</p>';
        exit();
        }

        
        
    $md5pass md5($_POST['pass2']);
        
    $activ_code rand(1000,9999);
        
    $server $_SERVER['HTTP_HOST'];
        
    $host ereg_replace('www.','',$server);
        
    mysql_query("INSERT INTO users
                      (`user_email`,`user_pwd`,`user_idnum`,`joined`,`activation_code`,`full_name`)
                      VALUES
                      ('
    $_POST[email]','$md5pass','$_POST[user_idnum]',now(),'$activ_code','$_POST[full_name]')") or die(mysql_error());

        unset(
    $_SESSION['ckey']);
        echo(
    "Registration Successful! An activation code has been sent to your email address with an activation link...");    
        
        exit;
        }    
                if (isset(
    $message)) {
           echo 
    '<font color="red">'$message'</font>';
           }
    ?> 
    <link href="styles.css" rel="stylesheet" type="text/css">
    <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
    <p>&nbsp;</p>
    <table width="65%" border="0" cellpadding="0" cellspacing="0">
      <tr> 
        <td class="mnuheader"><strong><font size="5">Register Account</font></strong></td>
      </tr>
      <tr> 
        <td class="forumposts"><form name="form1" method="post" action="register.php" style="padding:5px;">
            <p><br>
              Name: 
              <input name="full_name" type="text" id="full_name">
              </p>
            <p>Email: 
              <input name="email" type="text" id="email">
              </p>
            <p>Password: 
              <input name="pass1" type="password" id="pass1">
              Atleast 5 characters</p>
            <p>Retype Password: 
              <input name="pass2" type="password" id="pass2">
            </p>
            <p>
            ID Number:
             <input name="user_idnum" type="text" id="user_idnum">
             </p>
            <p>
              <input name="user_code" type="text" size="10">
              <img src="pngimg.php" align="middle">&nbsp; </p>
            <p align="center"> 
              <input type="submit" name="Submit" value="Register">
            </p>
          </form></td>
      </tr>
    </table>
    <div align="left"></div>
    </body>
    </html>
    Thanks ahead of time.

  • #2
    I assume that the code you posted is in two files and you combined them for your post.

    I would have all the code in one page and change the post action to: action="<?php echo $PHP_SELF;?>"> and delete the register.php page. Also you don't need exit(); , I would let the code run it's course through the whole page.






    ------------
    Leonard Whistler

    Comment


    • #3
      Use a DISPLAY code with a DIE code to fix this.
      Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

      Comment


      • #4
        PHP Code:
        $messsage .= '<p>Password does not match or empty.</p>'
        Check your variable names.

        Comment


        • #5
          When I delete exit(); I have the error Duplicate entry '' for key 2.

          Comment


          • #6
            Originally posted by eschuppe View Post
            When I delete exit(); I have the error Duplicate entry '' for key 2.
            This means you're attempting to perform an INSERT of duplicate data on a PRIMARY KEY or UNIQUE field. Check your database structure against the data input.

            Comment

            Working...
            X