0

Hi I wanted to add datum from a table. However, it does not show up in the XAMPP(MySQL)

What am I doing wrong. Took me a long time to see what is wrong but i cannot find any.

fyi.

config.php connects the PHPto MySQL. and clean.php cleans a variable.

<?php

    session_start();
    echo "<div style='text-align:right'><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1> </div>";
    if($_SESSION['SESS_admin'] == 0)
        {
            require("do_menu.php");
            echo "<div style='text-align:right'>
            <form action='SearchUser.php' method='POST'>
            <Table border='0' align='right'>
            <tr>
                <td >
                    <select name='SEARCH' id='SEARCH'>
                        <option value='ID_NO' selected='selected'>ID Number</option>
                        <option value='FNAME'>First Name</option>
                        <option value='LNAME' >Last Name</option>
                        <option value='MNAME'>Middle Name</option>
                        <option value='DATE'>Birthday</option>
                        <option value='SEX'>SEX</option>
                        <option value='AGE'>Age</option>
                        <option value='STATUS'>Status</option>
                        <option value='TEL_NO'>Landline Number</option>
                        <option value='ADDRESS'>Address</option>
                        <option value='OCCUPATION'>Occupation</option>
                        <option value='REFERRED_BY '>Referrals</option>
                        <option value='itResult'>Result</option>
                    </select>
                </td>
                <td rowspan =2><input name='SUBMIT' type='SUBMIT' id='SUBMIT' value='Search!'></td>
            </tr>
            <tr>
                <td><input name='INPUT' type='text' id='INPUT'></td>
            </tr>
            </table><br>
            </FORM> </div>";
        }
    else
        require("do_menu3.php");


    require("clean.php");
    require("config.php");  
    require("auth.php");
    require("do_html_header.php");
    do_html_header();
    do_menu();

?>

<?php
    if (!$_POST['SUBMIT']){
?>



    <center>
    <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST" name=register>
    <table width="400" border="0" cellspacing="1" cellpadding="0" align="center">
    <tr>
    <td bgcolor="yellow"><H1>Add Specialist</H1></td>
    </tr>
    <tr>
           <td width="100">
            <fieldset>
            <label for="name">name:</label>
                <input
                    type="text"
                    id="name"
                    name="name"
                    maxlength="100"
                    onkeyup="checkNameForLength(this);" />

            </fieldset>
            </td>
        </tr>
      <tr>
           <td width="100">
            <fieldset>
            <label for="spec_username">Specialist's Username:</label>
                <input
                    type="text"
                    id="spec_username"
                    name="spec_username"
                    maxlength="100"
                    onkeyup="checkNameForLength(this);" />

            </fieldset>
            </td>
        </tr>
        <tr>
           <td width="100">
            <fieldset>
            <label for="spec_password">Specialist's Password:</label>
                <input
                    type="text"
                    id="spec_password"
                    name="spec_password"
                    maxlength="28"
                    onkeyup="checkNameForLength(this);" />

            </fieldset>
            </td>
        </tr>
        <tr>
           <td width="100">
            <input type="hidden" name="online_check" id="online_check" size="50" value="Y">

            </td>
       </tr>
       <tr>
           <td width="100"><center><input name="SUBMIT" type="SUBMIT" id="SUBMIT" value="SUBMIT">
           <input type="RESET" value="RESET"></form>
           <form action="login-form.php"><input type="SUBMIT" name="Submit" value="Go Back!"/></center></form></td>

       </tr>
    </table>


<?php
    }
    else {

       //Array to store validation errors
       $errmsg_arr = array();

       //Validation error flag
       $errflag = false;

       //Function to sanitize values received from the form. Prevents SQL injection

       $name                      = clean($_POST['name']);
       $spec_username             = clean($_POST['spec_username']);
       $spec_password            = clean($_POST['spec_password']);
       $online_check              = clean($_POST['online_check']);


       $_SESSION["spec_id"]              = $spec_id;
       $_SESSION["name"]                 = $name;
       $_SESSION["spec_username"]        = $spec_username;
       $_SESSION["spec_password"]        = $spec_password;
       $_SESSION["online_check"]         = $online_check;

       //Input Validations

       if($name == '') {
           $errmsg_arr[] = 'Name missing';
           $errflag = true;
       }
       if($spec_username == '') {
           $errmsg_arr[] = 'Username missing';
           $errflag = true;
       }
       if($spec_password == '') {
           $errmsg_arr[] = 'Password missing';
           $errflag = true;
       }
       if($online_check == '') {
           $errmsg_arr[] = 'Online Check missing';
           $errflag = true;
       }



       //If there are input validations, redirect back to the registration form
       if($errflag) {
           $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
       session_write_close();
       print "You have input errors. These are:";
       print "<BR><UL>";
       for ($i=0; $i<sizeof($errmsg_arr); $i++) {
               print "<LI>$errmsg_arr[$i]";
           }
           print "</UL>";
       print "<A HREF=\"";
           print $_SERVER['PHP_SELF'];
           print "\">Go back</A>";
       exit();
       }
       else {
           echo "<center><BR><BR>You entered the following information:";

           echo "<BR>Name = $name";
           echo "<BR>Username = $spec_username";
           echo "<BR>Password = $spec_password";
           echo "<BR>Online Check = $online_check";

            $result = mysql_query("select * from specialist_info where spec_id = '$spec_id'");
           if(!(mysql_num_rows($result) == 0)) {
               print "<BR>User number $spec_id is already assigned to another User<BR><A HREF =\"".$_SERVER['PHP_SELF']. "\">Go Back</A>";
           @mysql_free_result($result);
           exit();
           }
       $result = mysql_query("INSERT INTO specialist_info (spec_id, name, spec_username, spec_password, online_check) VALUES('$spec_id', '$name', '$spec_username',spec_password( '$password'), '$online_check')");
           print ("<BR><BR>1 record added");

       }
   }
?>

</BODY>
</HTML>
2
  • seriously? please indicate where the error is Mar 29, 2011 at 22:57
  • the data that i suppose to put in the database is not showing up in the MySQL. Yes its serious. Mar 29, 2011 at 23:14

2 Answers 2

2

Here is your query line

 $result = mysql_query("
      INSERT INTO specialist_info (spec_id, name, spec_username, spec_password, online_check)
      VALUES('$spec_id', '$name', '$spec_username',spec_password( '$password'), '$online_check')");

What is spec_password( '$password') about?

spec_password is not a function. do you men to say $spec_password? mean $password to be array index? im not sure what you're going for

1
1

Try...

$result = mysql_query("INSERT INTO specialist_info(
spec_id,
name,
spec_username,
spec_password,
online_check
)VALUES(
'$spec_id',
'$name',
'$spec_username',
'".spec_password($password)."',
'$online_check')");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.