PHP not echoing information from HTML form
Posted: Thu Jul 22, 2010 11:48 am
Hi everyone,
I'm new to PHP and have come up against my first problem so thought I'd join this site to see if anyone can shed any light on the matter.
I'm currently designing and bulding a new website for myself and have succsessfully built the homepage and uploaded it to my domain space. I have a contact form which I've coded with HTML and styled with CSS and wanted to test the form fields are working by echoing out some of the data to the browser. However when the submit button is clicked the browser is directed to the 'contactform.php' page but it appears blank. Here is the respective code I have set up:
HTML form code:
<div id="formscontainer"><!------ Centering Form Container -->
<div id="formcolumnone"><!------ First Column -->
<div id="formlogo">
<a href="#"><img src="images/contactformlogo.png" title="Back to the homepage" border="none"/></a>
</div>
<div id="requiredfields"><!------ Required Info-->
<h1><font color="#FFFF00">Required fields marked with a*</font></h1>
</div><!------ End Required Info -->
<div id="leftform"><!------ Left Hand Form -->
<form action="contactform.php" method"post">
<fieldset class="first">
<label id="namefield" for="name">
<input type="text" id="name" name="name" value="*Name" />
</label>
<label id="emailfield" for="email">
<input type="text" id="name" name="email" value="*Email" />
</label>
<label id="websitefield" for="website">
<input type="text" id="website" name="website" value="*Website" />
</label>
</fieldset>
</form>
</div><!------ End Left Hand Form -->
</div><!------ End First Column -->
<div id="formcolumntwo"><!------ Second Column -->
<div id="rightform"><!------ Right Hand Form -->
<form action="contactform.php" method"post">
<fieldset class="second">
<label id="subject" for="subject">
<input type="text" id="subject" name="subject" value="*Subject" />
</label>
<label class="labelFive" >
<textarea ROWS="8" COLS="49" name="enquiry">*Enquiry</textarea>
</label>
</fieldset>
</form>
</div><!------ End Right Hand Form -->
</div><!------ End Second Column -->
<div id="formcolumnthree">
<div id="closeformbutton"><!------ Header Phone Number -->
<a href="#" title="You sure you don't want some Lemmonaid?"><h1><font color="#FFFF00">Close</font></h1></a>
</div><!------ End Header Phone Number -->
<div id="formbuttons">
<div id="resetbutton">
<form action="contactform.php" method"post">
<button type="reset" input type="reset" id="clear" action="reset form" style="border: 0; background: transparent"><img src="images/resetbutton.png" alt="submit" /></button>
</form>
</div>
<div id="submitbutton">
<form action="contactform.php" method"post">
<button type="submit" input type="submit" id="submit" action="submit form" style="border: 0; background: transparent"><img src="images/submitbutton.png" alt="submit" /></button>
</form>
</div>
</div>
</div>
</div><!------ End Centring Form Container -->
PHP code (to echo out just the name and email data for testing purposes):
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$subject = $_POST['subject'];
$enquiry = $_POST['enquiry'];
echo $name.'<br>' . $email;
?>
I would greatly appreciate any help and advice that anyone might be able to provide.
Thanks in advance.
Marc
I'm new to PHP and have come up against my first problem so thought I'd join this site to see if anyone can shed any light on the matter.
I'm currently designing and bulding a new website for myself and have succsessfully built the homepage and uploaded it to my domain space. I have a contact form which I've coded with HTML and styled with CSS and wanted to test the form fields are working by echoing out some of the data to the browser. However when the submit button is clicked the browser is directed to the 'contactform.php' page but it appears blank. Here is the respective code I have set up:
HTML form code:
<div id="formscontainer"><!------ Centering Form Container -->
<div id="formcolumnone"><!------ First Column -->
<div id="formlogo">
<a href="#"><img src="images/contactformlogo.png" title="Back to the homepage" border="none"/></a>
</div>
<div id="requiredfields"><!------ Required Info-->
<h1><font color="#FFFF00">Required fields marked with a*</font></h1>
</div><!------ End Required Info -->
<div id="leftform"><!------ Left Hand Form -->
<form action="contactform.php" method"post">
<fieldset class="first">
<label id="namefield" for="name">
<input type="text" id="name" name="name" value="*Name" />
</label>
<label id="emailfield" for="email">
<input type="text" id="name" name="email" value="*Email" />
</label>
<label id="websitefield" for="website">
<input type="text" id="website" name="website" value="*Website" />
</label>
</fieldset>
</form>
</div><!------ End Left Hand Form -->
</div><!------ End First Column -->
<div id="formcolumntwo"><!------ Second Column -->
<div id="rightform"><!------ Right Hand Form -->
<form action="contactform.php" method"post">
<fieldset class="second">
<label id="subject" for="subject">
<input type="text" id="subject" name="subject" value="*Subject" />
</label>
<label class="labelFive" >
<textarea ROWS="8" COLS="49" name="enquiry">*Enquiry</textarea>
</label>
</fieldset>
</form>
</div><!------ End Right Hand Form -->
</div><!------ End Second Column -->
<div id="formcolumnthree">
<div id="closeformbutton"><!------ Header Phone Number -->
<a href="#" title="You sure you don't want some Lemmonaid?"><h1><font color="#FFFF00">Close</font></h1></a>
</div><!------ End Header Phone Number -->
<div id="formbuttons">
<div id="resetbutton">
<form action="contactform.php" method"post">
<button type="reset" input type="reset" id="clear" action="reset form" style="border: 0; background: transparent"><img src="images/resetbutton.png" alt="submit" /></button>
</form>
</div>
<div id="submitbutton">
<form action="contactform.php" method"post">
<button type="submit" input type="submit" id="submit" action="submit form" style="border: 0; background: transparent"><img src="images/submitbutton.png" alt="submit" /></button>
</form>
</div>
</div>
</div>
</div><!------ End Centring Form Container -->
PHP code (to echo out just the name and email data for testing purposes):
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$subject = $_POST['subject'];
$enquiry = $_POST['enquiry'];
echo $name.'<br>' . $email;
?>
I would greatly appreciate any help and advice that anyone might be able to provide.
Thanks in advance.
Marc