Hello everyone!

I know this is very numb question. But can anyone please help me on seeking the error? I already search the error for the past few days but still cannot find where it is wrong. Anyway there is no error come when its debug but the data not enter to the database. Please kindly help me. Thanks!

register.php

<?php
if (isset($_POST['submit'])){
$link = mysql_connect("localhost","root","root") or die ("Could not connect to the Database Server!");
$db = mysql_select_db("ija", $link) or die ("Could not select Database!");
mysql_query("INSERT INTO staffdb (staff_name,staff_email,staff_username,staff_password) VALUES ('$staff_name','$staff_email','$staff_username','$staff_password')");
$db_close=mysql_close();}
?>

<script type="text/javascript">
function show_alert()
{
var msg = "Successful : Your data saved";
alert(msg);
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PROTON - Internal Job Application Online</title>

<link href="./style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
    color: #000;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #000;
}
a:hover {
    text-decoration: underline;
    color: #333;
}
a:active {
    text-decoration: none;
    color: #000;
}
.style1 {
    font-size: xx-large;
    color: #FFFFFF;
}
.style4 {font-size: 12px}
-->
</style></head>

 <form name="form1" method="post" action="index_user.php">
<body>

<div id="nav">
  <p align="center"><span class="style1">Internal Job Application</span></p>


  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="468" border="0" align="center">
    <tr>
      <td width="170"><span class="style4">Full Name</span></td>
      <td width="5"><div align="center">:</div></td>
      <td width="279">
          <label>
          <input name="staff_name" type="text" id="staff_name" size="40" />
          </label>      </td>
    </tr>
    <tr>
      <td><span class="style4">Email</span></td>
      <td><div align="center">:</div></td>
      <td><input name="staff_email" type="text" id="staff_email" size="40"/></td>
    </tr>
    <tr>
      <td><span class="style4">Username</span></td>
      <td><div align="center">:</div></td>
      <td>
        <label>
        <input name="staff_username" type="text" id="staff_username" size="40"/>
      </label></td>
    </tr>
    <tr>
      <td><span class="style4">Password</span></td>
      <td><div align="center">:</div></td>
      <td>
          <label>
          <input name="staff_password" type="text" id="staff_password" size="40" />
          </label>   </td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">

          <label>
          <input name="submit" type="submit" id="submit" value="Submit" onClick="show_alert()"/>
          </label>
          <label>
            <input type="reset" name="Reset" value="Reset" />
            </label>

        </div></td>
    </tr>
  </table>



</div>
</body>
  </form>
</html>

Recommended Answers

All 3 Replies

have you try checking your query to you database editor?check first if its alright
and im just little confuse your form redirects to index_user.php and the script to enter data is on the register.php what about it?

Hi,
The variable $staff_name (and the others) are not defined before query.
After submit you should get in those variables the form data, like this:

$staff_name = $_POST['staff_name'];
// ... similar with the other variables

yep i know =)
But you said the problem here is you cannot enter data from database..right?
just a question what is the content of your index_user.php, is this the file where your inserting script recides thats why you redirect the form to it? cause what i saw is your inserting script is in the register.php .....
or
can you elaborate more...
cause what i iderstan to your code is you have this:
first you have the registration form where you redirect it to index_user.php(i dont know y)
second is you have an inserting query IF(the the form already submited) ---this query is for your registration form?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.