Jump to content

page going blank when mixing php with html


blink359

Recommended Posts

Hi im trying to mix php and html in a form however when i do this the whole page disapears and i dont know why

the working form is:

http://valiantflight.comlu.com/emailer/contact.php

<html>
<head>
<title>Contact Us</title>
</head>
<body>
<fieldset>
<legend>Contact Us</legend>
<form action="contact.php" method="post">

<input type="hidden" name="frmsubmit">
Your Email:*<br>



<input type="text" name="email"><br>
Subject:*<br>
<select name="subject">
<option value=""></option>
<option value="1">Recruitment</option>
<option value="2">Absense</option>
<option value="3">Enquiry</option>
</select>



<br>
Message:*<br>
<textarea name="message" cols="50" rows="5"></textarea>



<br>
        <?php           require_once('recaptchalib.php');
           $publickey = "6LeB8LwSAAAAAKwvC3HWJNwWw9vYiSEkvFEvDduD"; // you got this from the signup page
           echo recaptcha_get_html($publickey);
         ?> 




<br>
<input name"Submit" type="submit" value="Send Email">

</form>
Required fields are marked with a *<br><br>
<?php
if(isset($_POST['frmsubmit'])){
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

//checcking that all relevent information is entered and correct
require_once('recaptchalib.php');
$privatekey = "6LeB8LwSAAAAAA_0IIEnAxL5uOau0TBm83Iog7Ey";
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    

if(!$message || !$email || !$subject)
{
	$errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>";
}
if (!$resp->is_valid) 
{
	$errmessage ="<font color='red'>The text entered does not match the picture provided.</font>";

}

//Sending the email if nothing is wrong
if(!$errmessage)
{
header("location:send.php?subject=".$subject."&email=".$email."&message=".$message."");
}else{

	echo $errmessage;
}
}
?>
</fieldset>
<br><br><br>
</body>
</html>

and the one that doesnt work is:

http://valiantflight.comlu.com/emailer/test/contact.php

<html>
<head>
<title>Contact Us</title>
</head>
<body>
<fieldset>
<legend>Contact Us</legend>
<form action="contact.php" method="post">
<?php
if(isset($_POST['frmsubmit'])){
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

//checcking that all relevent information is entered and correct
?>

<input type="hidden" name="frmsubmit">
Your Email:*<br>
<input type="text" name="email">
<?php
if(!$email)
{
	$errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>";
	echo("<font color='red'><br>Please enter your email.</font>");
}
?>
<br>
Subject:*<br>
<select name="subject">
<option value=""></option>
<option value="1">Recruitment</option>
<option value="2">Absense</option>
<option value="3">Enquiry</option>
</select>
<?php
if(!$subject)
{
	$errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>";
	echo("<font color='red'><br>Please select a subject.</font>");
}
?>

<br>
Message:*<br>
<textarea name="message" cols="50" rows="5"></textarea>
<?php

if(!$message)
{
	$errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>";
	echo("<font color='red'><br>Please enter a message to send.</font>");
}

?>


<br>
        <?php 
require_once('recaptchalib.php');
$publickey = "6LeB8LwSAAAAAKwvC3HWJNwWw9vYiSEkvFEvDduD"; // you got this from the signup page
echo recaptcha_get_html($publickey);
require_once('recaptchalib.php');
$privatekey = "6LeB8LwSAAAAAA_0IIEnAxL5uOau0TBm83Iog7Ey";
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         	if (!$resp->is_valid) 
{
	$errmessage ="<font color='red'>Some parts of the form have not been entered correctly and have been marked above</font>";
	echo("<font color='red'>The text you entered does not match the picture provided.</font>");

}
?>


<br>
<input name"Submit" type="submit" value="Send Email">

</form>
Required fields are marked with a *<br><br>
<?php
    

//Sending the email if nothing is wrong
if(!$errmessage)
{
header("location:send.php?subject=".$subject."&email=".$email."&message=".$message."");
}else{

	echo $errmessage;
}
}
?>
</fieldset>
<br><br><br>
</body>
</html>

 

If anyone can help it would be really great

 

Thanks,

 

 

Blink359

All of your form html is inside the if(isset($_POST['frmsubmit'])) { conditional statement. By that logic the form will not display unless it has already been submitted. See how that could be a little bit of a problem?

Archived

This topic is now archived and is closed to further replies.

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