Jump to content

No data entered into database


ct2k7

Recommended Posts

Hi,

 

 

I'm just having trouble with this script, of which I can't get to work.

Below is my PHP script for a staff application script, called apps.php

 

 

<? 
error_reporting(E_ALL);  

/* 
function myCheckDNSRR($hostName, $recType = ''){ 
     if(!empty($hostName)){ 
       if($recType == '') $recType = "MX"; 
        
       // Lookup the domain - check its not a dummie. 
       exec("nslookup -type=$recType $hostName", $result); 
       foreach ($result as $line){ 
         if(eregi("^$hostName",$line)){ 
           return true; 
         } 
       } 
       return false; 
     } 
     return false; 
    } 
*/ 
if(isset($_POST['submit'])) { 
    mysql_connect('localhost','control_apps','password','control_apps'); 
    mysql_select_db('control_apps'); 
     
    //$_SERVER["REMOTE_ADDR"]) = $IP; 
    $name = $_POST['name']; 
    $dob = $_POST['DOB']; 
    $email = $_POST['Email']; 
    $position = $_POST['position']; 
    $why = $_POST['Why']; 
    $exp = $_POST['Experience']; 
                       
     /*                 //if (!myCheckDNSRR($_POST['email'], "MX")) { 
                          echo 'Invalid Email'; 
                          $die = 1; 
                      } //if (!myCheckDNSRR($mailDomain, "MX")) 
    */ 
    if(!empty($_POST['name']) && !empty($_POST['email']) && $die != 1) { 
    echo 'Thanks for your application, expect an email reply shortly'; 
    mysql_query('INSERT INTO applications(ID,Name,DOB,Email,Position,Why,Experience) VALUES(NULL,$name,$dob,$email,$pos,$why,$exp)') or die(mysql_error()); 
    } 
} else { 
?> 
<html> 
<body><form action="apps.php" method="post"><font size="1px" face="Verdana"> 
Name: <br><input type="text" name="name" ><br> 
Date Of Birth: <br><input type="text" name="DOB" ><br> 
Email: <br><input type="text" name="Email" ><br> 
Position Applying for: <br ><select name="position"> 
<option value="Systems Admin"><font size="1px" face="Verdana">Systems Administrator</font></option> 
<option value="Web Developer"><font size="1px" face="Verdana">Website Developer</font></option> 
<option value="Marketing MGR"><font size="1px" face="Verdana">Marketing Manager</font></option> 
</select><br> 
Why do you want to work with us?: <br><textarea name="Why" cols="40" rows="5"></textarea><br > 
Do you have any previous experience? Explain: <br><textarea name="Experience" cols="40" rows="5"></textarea><br> 

<input type="submit" value="Send Application" name-"submit" /> 
</font></form><?php } ?></body> 
</html> 
When submitting the form, the page returns blank, no acknowledgement that the data has been entered, since there is no echo that thanks for the app, nor is there anything in the table.

 

When submitting the form, the page returns blank, no acknowledgement that the data has been entered, since there is no echo that thanks for the app, nor is there anything in the table.

 

PHP parses no errors, so all looks clean.

 

 

Any ideas with what's going wrong? All comments are greatly appreciated

Link to comment
Share on other sites

You need single quotes around your variable names in your query, and you should encapsulate the entire query in double quotes and not single.

 

Make sure you turn on error display as well as your reporting, a blank page is a indicator of a syntax error.

 

Use <?php instead of just <? short tag to make your code portable.

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.