0

Hello All,

I am a PHP newbie and have all my resources set up( by that I mean PHP,Apache server etc all working fine)

I have an html file and a PHP script to handle the inputs from the html form. However when I hit submit to send the data to the PHP script I get a blank page.

Below are my files.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/2000/REC -xhtml1-20000126/DTD/xhtml1-transitional.dtd">

<html xmlns ="http://www.w3.org/1999/xhtml" xml :lang="en" lang ="en">
<head>
 	 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
	<title>HTML Form</title>
</head>

<body>

<!--Script 2.1 -from.html -->

<form action = "handle_form.php "  method="post">

<fieldset><legend> Enter you information in the form below :</legend>
<p><b>Name :</b> <input type = "text" name = "name" size ="20" maxlength = "40"/></p>

<p><b>Email :</b> <input type = "text" name ="email" size="40" maxlength ="40"/></p>

<p><b>Gender  :</b> <input type = "radio" name ="gender" value ="M" />Male
		   <input type = "radio" name ="gender" value ="F" />Female
</p>
<p><b>Age :</b>
 <select name = "age" >
	<option value ="0-30">Under 30</option>
	<option value ="30-60">Between 30 and 60</option>
	<option value ="60+">Over 60 </option>
</select></p>
<p><b>Comments :</b><textarea name = "comments" rows ="3" cols="50"></textarea></p>
</fieldset>

<div align = "center"><input type = "submit" name ="submit" value ="Submit Information"/><div>

</form>

****...and here is the PHP script handling the form above*************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/2000/REC -xhtml1-20000126/DTD/xhtml1-transitional.dtd">

<html xmlns ="http://www.w3.org/1999/xhtml" xml :lang="en" lang ="en">
<head>
 	 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
	<title>Form Feedback</title>
</head>

<body>

<? php # Script 2.2 -handle_form.php

echo "<p> Thank you ,<b>$name</b> for the following comments :<br/><tt>$comments</tt><p>We will reply to you at <i>$email</i>.</p>";

?>

</body>

</html>

I'd be grateful if some can explain why the handle_form.php shows up BLANK when I clik submit from the form.html.

Thank You.

4
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by jblacdao
0

Hello All,

I am a PHP newbie and have all my resources set up( by that I mean PHP,Apache server etc all working fine)

I have an html file and a PHP script to handle the inputs from the html form. However when I hit submit to send the data to the PHP script I get a blank page.

Below are my files.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/2000/REC -xhtml1-20000126/DTD/xhtml1-transitional.dtd">
 
<html xmlns ="http://www.w3.org/1999/xhtml" xml :lang="en" lang ="en">
<head>
     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
    <title>HTML Form</title>
</head>
 
<body>
 
<!--Script 2.1 -from.html -->
 
<form action = "handle_form.php " method="post">
 
<fieldset><legend> Enter you information in the form below :</legend>
<p><b>Name :</b> <input type = "text" name = "name" size ="20" maxlength = "40"/></p>
 
<p><b>Email :</b> <input type = "text" name ="email" size="40" maxlength ="40"/></p>
 
<p><b>Gender :</b> <input type = "radio" name ="gender" value ="M" />Male
         <input type = "radio" name ="gender" value ="F" />Female
</p>
<p><b>Age :</b>
<select name = "age" >
    <option value ="0-30">Under 30</option>
    <option value ="30-60">Between 30 and 60</option>
    <option value ="60+">Over 60 </option>
</select></p>
<p><b>Comments :</b><textarea name = "comments" rows ="3" cols="50"></textarea></p>
</fieldset>
 
<div align = "center"><input type = "submit" name ="submit" value ="Submit Information"/><div>
 
</form>

****...and here is the PHP script handling the form above*************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/2000/REC -xhtml1-20000126/DTD/xhtml1-transitional.dtd">
 
<html xmlns ="http://www.w3.org/1999/xhtml" xml :lang="en" lang ="en">
<head>
     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
    <title>Form Feedback</title>
</head>
 
<body>
 
<? php # Script 2.2 -handle_form.php
 
echo "<p> Thank you ,<b>$name</b> for the following comments :<br/><tt>$comments</tt><p>We will reply to you at <i>$email</i>.</p>";
 
?>
 
</body>
 
</html>

I'd be grateful if some can explain why the handle_form.php shows up BLANK when I clik submit from the form.html.

Thank You.

Hi,
you can do that functions in a single page itself
without doing two seprate pages.I have altered your code and i have given that below .you check that and if any doubt means ask upto my knowledge if know i will explain

the code

<html xmlns ="http://www.w3.org/1999/xhtml" xml :lang="en" lang ="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>HTML Form</title>
</head>
<?php
$name=$_REQUEST;
$comments=$_REQUEST;
$submit=$_REQUEST;
if($submit)
{
$ee="Thank you $name for the following comments :$commentsWe will reply to you at $email";
}
?>
<body>
<!--Script 2.1 -from.html -->
<form action="" method="post">
<fieldset><legend> Enter you information in the form below :</legend>
<p><? echo $ee;?> </p>
<p><b>Name :</b> <input type = "text" name = "name" size ="20" maxlength = "40" value="<?=$name?>"/></p>
<p><b>Email :</b> <input type = "text" name ="email" size="40" maxlength ="40"/></p>
<p><b>Gender :</b> <input type = "radio" name ="gender" value ="M" />Male
<input type = "radio" name ="gender" value ="F" />Female
</p>
<p><b>Age :</b>
<select name = "age" >
<option value ="0-30">Under 30</option>
<option value ="30-60">Between 30 and 60</option>
<option value ="60+">Over 60 </option>
</select></p>
<p><b>Comments :</b><textarea name="comments" rows ="3" cols="50"><?=$comments?></textarea></p>
</fieldset>
<div align = "center"><input type ="submit" name="submit" value="submit"/><div>
</form>

0

Hi,
you can do that functions in a single page itself
without doing two seprate pages.I have altered your code and i have given that below .you check that and if any doubt means ask upto my knowledge if know i will explain

the code

<html xmlns ="http://www.w3.org/1999/xhtml" xml :lang="en" lang ="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>HTML Form</title>
</head>
<?php
$name=$_REQUEST;
$comments=$_REQUEST;
$submit=$_REQUEST;
if($submit)
{
$ee="Thank you $name for the following comments :$commentsWe will reply to you at $email";
}
?>
<body>
<!--Script 2.1 -from.html -->
<form action="" method="post">
<fieldset><legend> Enter you information in the form below :</legend>
<p><? echo $ee;?> </p>
<p><b>Name :</b> <input type = "text" name = "name" size ="20" maxlength = "40" value="<?=$name?>"/></p>
<p><b>Email :</b> <input type = "text" name ="email" size="40" maxlength ="40"/></p>
<p><b>Gender :</b> <input type = "radio" name ="gender" value ="M" />Male
<input type = "radio" name ="gender" value ="F" />Female
</p>
<p><b>Age :</b>
<select name = "age" >
<option value ="0-30">Under 30</option>
<option value ="30-60">Between 30 and 60</option>
<option value ="60+">Over 60 </option>
</select></p>
<p><b>Comments :</b><textarea name="comments" rows ="3" cols="50"><?=$comments?></textarea></p>
</fieldset>
<div align = "center"><input type ="submit" name="submit" value="submit"/><div>
</form>

Thanks for the help....but the problems still persists and I'd try to see if something else is wrong.

0

Your code probably has an error in it but you can't see it because error reporting is probably turned off. Put this at the top of your page:

error_reporting(E_ALL);

so see the errors.

0

Or if you just copy pasted azarudeen's code and didn't put in the page value for the action property in the form tag, you'll definitely get a blank page ^^

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.