Jump to content

Script not working?


Drewdle

Recommended Posts

The following script doesn't seem to work?

 

I re-used a registration script that I have which works fine, just changing the details where necessary but it doesn't work and shows no errors, when I fill out the form and click submit it just displays the form again, no success message, no error message and it doesn't add the info into the database, however when I run the same query through phpmyadmin it works...

 

<?php 
include ('header.php');
?></center>
<div class=content>
<?php  
if(!empty($_POST['username']) && !empty($_POST['password']))  
{  
    $fname = mysql_real_escape_string($_POST['first']);
    $lname = mysql_real_escape_string($_POST['last']);    
    $email = mysql_real_escape_string($_POST['email']);
    $sia = mysql_real_escape_string($_POST['sia']);
    $no = mysql_real_escape_string($_POST['number']);
  
     $checknumber = mysql_query("SELECT * FROM staff WHERE no = '".$no."'");  
  
     if(mysql_num_rows($checknumber) == 1)  
     {  
        echo "<b>Error</b>";  
        echo "Mobile number in use by another employee!";  
     }  
     else  
     {  
        $addstaff = mysql_query("INSERT INTO staff (fname, lname, email, no, sia) VALUES('".$fname."', '".$lname."', '".$email."', '".$no."', '".$sia."')");  
        if($addstaff)  
        {  
            echo "<b>Success!</b>";  
            echo "Employee added to the database, click <span class=1><a href=stafflist.php>here</a></span> to view employee's";  
        }  
        else  
        {  
            echo "<b>Error</b>";  
            echo "<p>There was a problem adding the employee, please try again.</p>";                
} 
     }  
}  
else  
{  
    ?>  
   <b>Add an Employee</b>  
  <br><br>
   Please enter the details below to add an employee to the database.  
  <br><br>
    <form method="post" action="addstaff.php" name="addstaffform" id="addstaffform"> 
    <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0>
<b>Required Information:</b><br><br>
<tr><td>  
        <b>First Name:</b>
</td><td>
        <input type="text" name="first" id="first" />
</td></tr><tr><td>
        <b>Last Name:</b>
</td><td>
        <input type="text" name="last" id="last" />
</td></tr><tr><td>  
        <b>Email Address:</b>
</td><td>
        <input type="text" name="email" id="email" />
</td></tr></table></td><td valign=top>
<table border=0>
<b>More Information:</b><br><br>
<tr><td>
     <b>SIA License Number:</b>
</td><td>
     <input type="text" name="sia" id="sia">
</td></tr><tr><td>
     <b>Contact Number:</b>
</td><td>
     <input type="text" name="no" id="no">
</tr></td></td>
</table> </td></tr> </table>
        <input type="submit" name="add" id="add" value="Add Employee" class=btn />  
    </form>  
  
    <?php  
}  
?>  </div>
<?php
include ('footer.php'); 
?>

 

I don't understand it? Whats wrong with it?

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.