Jump to content

Please help form just showing Blank


VinceGledhill
 Share

Recommended Posts

Hi People.

 

Does anyone have any idea why this form is showing as a blank page on my site?  Can you see what I've missed?

 

<!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=iso-8859-1" />
<title>Stranded Flyer</title>
</head>

<body>

<?php

$host = 'localhost';
$usr = "the_user";
$password = 'thepassword';
$db_name = 'thedbname';

//connect to database
mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error());
mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error());

$surname = mysql_real_escape_string($_POST['surname']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$phone1 = mysql_real_escape_string($_POST['phone1']);
$phone2 = mysql_real_escape_string($_POST['phone2']);
$location = mysql_real_escape_string($_POST['location']);
$qualifications = mysql_real_escape_string($_POST['qualifications']); 
$expertise = mysql_real_escape_string($_POST['expertise']);
$assistance = mysql_real_escape_string($_POST['assistance']);
$languages = mysql_real_escape_string($_POST['languages']);
$e-mail = mysql_real_escape_string($_POST['e-mail']);
$consent = mysql_real_escape_string($_POST['consent']);
$published = mysql_real_escape_string($_POST['published']);
$comments = mysql_real_escape_string($_POST['comments']); 
$other_info = mysql_real_escape_string($_POST['other_info']);



$errorstring = ""; // default value of errorstring

function makeSafe($value)
{
    if (get_magic_quotes_gpc())
    {
        $value = stripslashes($value); 
    }
    
    $value = mysql_real_escape_string($value);
    
    return $value;
}

if(isset($_POST['submit'])) {
// Validate all the code inputs

// Captcha Validation

require_once('recaptchalib.php');
$privatekey = "6Ld2xscSAAAAADwh3mCFkTObSHLAEKUAcU3ocpSv";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    $errorstring = $errorstring. "Invalid CAPTCHA, please try again";
  } else {

if ($surname =="")
$errorstring = $errorstring. "Surname<br>";
if ($phone1 =="")
$errorstring = $errorstring. "phone1<br>";	
if ($phone2 =="")
$errorstring = $errorstring. "phone2<br>";
if ($location =="")
$errorstring = $errorstring. "location<br>";
if	($qualifications =="")
$errorstring = $errorstring. "qualifications<br>";
if ($assistance =="")
$errorstring = $errorstring. "assistance<br>";
if ($languages =="")
$errorstring = $errorstring. "languages<br>";
if ($e-mail =="")
$errorstring = $errorstring. "e-mail<br>";
if ($consent =="")
$errorstring = $errorstring. "consent<br>";
if ($published =="")
$errorstring = $errorstring. "published<br>";
if ($comments =="")
$errorstring = $errorstring. "comments<br>";	
if ($other_info =="")
$errorstring = $errorstring. "other info<br>";

// does the errorstring = "nothing"?

}
// Figure out which error message to show i.e. field validation or CAPTCHA
if ($errorstring !="")
   if (strstr($errorstring,"CAPTCHA")) echo $errorstring;
  else echo "You have not put anything in the following fields: <br><br> $errorstring";
//echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\"";
//die ("Please try again, ensuring that you fill out all the fields!");
else 
{


//echo "Your data has been saved";


$insert_query = "INSERT INTO HelperFormData (surname, firstname,phone1, phone2, location, qualifications, expertise, assistance, languages, e-mail, consent, published, comments, other_info,) VALUES ('$surname', '$firstname', '$phone1','$phone2', '$location', '$qualifications', '$expertise', '$assistance', '$languages', '$e-mail', '$consent', '$published', '$comments', '$other_info')";
$insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query);

$id = mysql_insert_id();

echo "Thank you, Your details have been submitted.";
//include "resultcard.php";

// Output what the form looks like

// End of how the form looks 

}
}

if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring)))
{
?>

<form name = "form1" method ="post" action="">
<table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#dddddd">
  <caption>
    Submit Your  Details
  </caption>
  <tr>
    <td width = "50"> </td>
    <td width = "240"> </td>
    <td width = "250"> </td>
    <td width = "160"><b>Example Input</b></td>
  </tr>
  
  <tr>
    <td> </td>
    <td>Surname</td>
    <td><input type='text' name='surname' size = '40' maxlength='30' value = '<?php echo $surname; ?>'></td>
    <td>Smith</td>
  </tr>
  
  <tr>
    <td> </td>
    <td>First Name</td>
    <td><input type='text' name='firstname' size = '40' maxlength='30' value = '<?php echo $firstname; ?>'></td>
    <td>Bill</td>
  </tr>
  
  <tr>
    <td> </td>
    <td>Phone 1</td>
    <td><input type='text' name='phone1' size = '40' maxlength='30' value = '<?php echo $phone1; ?>'></td>
    <td>07777 777777</td>
  </tr>
  
  
  
  <tr>
    <td> </td>
    <td>Phone 2</td>
    <td><input type='text' name='phone2' size = '40' maxlength= '30'value = '<?php echo $phone2; ?>'></td>
    <td>0118 123 4567</td>
  </tr>
  <tr>
    <td> </td>
    <td>Location</td>
    <td><input type='text' name='location' size = '40' maxlength='40'value = '<?php echo $location; ?>'></td>
    <td>52.289071,-1.952004</td>
  </tr>
  <tr>
    <td> </td>
    <td>Qualifications</td>
    <td><input type='text' name='qualifications'  size = '40' maxlength='30' value = '<?php echo $qualifications; ?>'></td>
    <td>Electrician</td>
  </tr>
  <tr>
    <td> </td>
    <td>Expertise</td>
    <td><input type='text' name='qualifications'  size = '40' maxlength='30' value = '<?php echo $expertise; ?>'></td>
    <td>Flexwings</td>
  </tr>
  <tr>
    <td> </td>
    <td>Assistance Offered</td>
    <td><input type='text' name='assistance' size = '40' maxlength='50' value = '<?php echo $assistance; ?>' /></td>
    <td>Trailer and Tow Car</td>
  </tr>
  <tr>
    <td> </td>
    <td>Language Skills</td>
    <td><input type='text' name='published' size = '40' maxlength='50' value = '<?php echo $language; ?>' /></td>
    <td><p>English / Spanish</p></td>
  </tr>
  <tr>
    <td> </td>
    <td>E-Mail</td>
    <td><input type='text' name='comments' size = '40' maxlength='50' value = '<?php echo $e-mail; ?>' /></td>
    <td><p>example@mail.net</p></td>
  </tr>
  <tr>
    <td> </td>
    <td>Consent</td>
    <td>
      <select name = "surface">
        <option value = "Yes" <?php if ($_POST['consent'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option>
        <option value = "No" <?php if ($_POST['consent'] == 'No') { echo 'selected="selected"'; } ?>>No</option>
        
      
  </select>
      
      </td>
    <td>Yes</td>
  </tr>
  <tr>
    <td> </td>
    <td>Published</td>
    <td>
    
     <select name = "food">
     <option value = "Yes" <?php if ($_POST['published'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option>
        <option value = "No" <?php if ($_POST['published'] == 'No') { echo 'selected="selected"'; } ?>>No</option>
</select>
    
    </td>
    <td>Yes</td>
  </tr>
  <tr>
    <td> </td>
    <td>Comments</td>
    <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td>
    <td>As much info as possible 500 characters max</td>
  </tr>
  <tr>
    <td> </td>
    <td>Other Info</td>
    <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td>
    <td>As much info as possible 500 characters max</td>
  </tr>
  <tr>
    <td> </td>
    <td><input type='submit' name='submit' value='Submit Your Info' /></td>
    <td colspan="2">
      <? require_once('recaptchalib.php');
  $publickey = "6Ld2xscSAAAAAH3_KiJoRLR4sEWFFQR4yAr5F1xi"; // you got this from the signup page
  echo recaptcha_get_html($publickey);?></td>
  </tr>
</table>
</form>


</body>
</html>
<?php } ?>

Link to comment
Share on other sites

What do you mean by blank? You can't see no form?

 

Something I did notice is that you're only showing the form if Submit has a value.

(isset($_POST['submit'])

Wouldn't you want that to be

(!isset($_POST['submit'])

Link to comment
Share on other sites

Are you meant to be looking to see if the $errorstring ISN'T empty? I'm not quite sure on how your form needs to work.

 

I assume you need to check if $errorstring IS empty?

 

Sorry if I am wrong.

Link to comment
Share on other sites

You have a fatal parse error on line 30, because php variables cannot contain a - sign.

 

You need to be developing and debugging your code on a development system with php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you find basic errors like this. You will save a TON of time.

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.