blank page after form submission

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

jaydoh73
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Sep 25, 2011 10:07 am

blank page after form submission

Postby jaydoh73 » Sun Sep 25, 2011 10:18 am

I'm pretty new to php & I realize this is a common question, but I'm stumped. I've made a form within a html page which directs to a php file. The direction works. However, when I click submit it goes directly to a blank page. I placed the error reporting code in the beginning of the script & have work out a few errors line by line.. but nothing comes up for the issue at hand. I think I may have the html portion wrong. Also the e-mails don't seem to be going through. Could this be because the error explained above isn't allowing the script to complete before the e-mail is sent?

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

// $Id: index.php,v 1.94 2007/12/26...

if(isset($_POST['email'])) {

$email_to = "ordietryingodt@yahoo.com";
$email_subject = "New Recruit To Add";

function died($error) {
// your error code can go here\par
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['QL_Name']) ||
!isset($_POST['Age']) ||
!isset($_POST['Country']) ||
!isset($_POST['Game_Type'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}

$QL_Name = $_POST['QL_Name']; // required
$Age = $_POST['Age']; // required
$Country = $_POST['Country']; // required
$Game_Type = $_POST['Game_Type']; // not required

$error_message = "";
$Country = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$QL_Name)) {
$error_message .= 'Please enter your residing country.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$Age)) {
$error_message .= 'Please enter you QL name.<br />';
}
if(!preg_match($string_exp,$Country)) {
$error_message .= 'Please enter your age.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\\n\\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "QL Name: ".clean_string($QL_Name)."\\n";
$email_message .= "Age: ".clean_string($Age)."\\n";
$email_message .= "Country: ".clean_string($Country)."\\n";
$email_message .= "Game Type: ".clean_string($Game_Type)."\\n";
?>
<!
</head>
<body background="diamondplate.jpg" alink="#c0c0c0" link="#c0c0c0" bgcolor="#000000"
text=#ffffff vLink=#c0c0c0><font size="1">
<p align="center">
<table border="0" cellspacing="0" cellpadding="3" width="100%" bgcolor="#000000"
align=center>
<tbody>
<tr>
<td>
<p align="center"><img border="0" hspace="0" src="ODTlogo1.gif" width="215"
height=89></p>
<p align="center"><img border="0" hspace="0" src="ODTlogo2.gif" width="192"
height=23></p></td></tr></tbody></table></p>
<p></font>&nbsp;</p>
<p align="center"><font size="5" face="Verdana"></font>&nbsp;</p>
<p align="center"><font size="5" face="Verdana"></font>&nbsp;</p>
<p align="center"><font size="5" face="Verdana">Thank you! We will send your clan
invite asap.</font></p>
<p align="center"><font size="5" face="Verdana">We look forward to fragging with
you.</font></p></body></html>
>
<?php
}
?>

jorgepinho
New php-forum User
New php-forum User
Posts: 101
Joined: Tue Jul 05, 2011 5:41 am
Location: Portugal
Contact:

Re: blank page after form submission

Postby jorgepinho » Mon Sep 26, 2011 2:42 am

Hi,

You dont seam to be sending any email. mail(...) missing

As far as I can see, the blank page means that everything is OK (no errors doesnt mean it works)

jaydoh73
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Sep 25, 2011 10:07 am

Re: blank page after form submission

Postby jaydoh73 » Mon Sep 26, 2011 3:19 am

$email_to = "ordietryingodt@yahoo.com"; What am I missing.

Also, there's a whole wall of html on the bottom so no it shouldn't display a blank page.. I think it's a formatting error that I just don't know (yeah I'm a noob). I missing a tag? onsubmit maybe?

yassinebelkaid87
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Oct 23, 2011 12:38 pm

Re: blank page after form submission

Postby yassinebelkaid87 » Sun Oct 23, 2011 2:50 pm

Well, you must have a mail() function, this function that will send the data entered by your users to your email address. if there's a blank page, it means either there's no error and in this case it should display a success message, but i think there's an error but it's not shown maybe because you didn't declare, or you didn't echo it to be displayed, i noticed that in your : $string_exp = "/^[A-Za-z .'-]+$/"; and you made this condition for age : if(!preg_match($string_exp,$Age)). this is wrong, because age should be a number (integer) not a text (string), so it should be $string_exp = "/^[0-9]+$/"; and you can use this function : if(is_numeric($age)).

Good Luck.


Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests