Forum Moderators: coopster
<?
if(isset($_POST['submit_form'])) {
$error_msg = null;
# Default error_header
$error_header = "The following errors occured, Please rectify them before continuing<br>";
# error checking
if(!$_POST['name']) {
$error_msg .= "Please Fill in the Name field<br>";
}
if(!$_POST['email']) {
$error_msg .= "Please fill in the email field<br>";
}
if(!$_POST['suggestion']) {
$error_msg .= "Please fill in a suggestion<br>";
}
# end error checking.
if(!$error_msg) {
# if everything ok,
# define variables from the posted data
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$suggestion = $_POST ['suggestion'];
$messagetype = $_POST['messagetype'];
header("Location: thankyou.php");
}
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="bluegrass.css">
</head>
<body>
<?php
include ('header1.inc');
?>
<div class="content">
?>
<div class="content">
<? if(isset($error_msg)) {?>
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2" align="center"><? echo $error_header?><br></td>
</tr>
</table>
<?
}
}
?>
<center>
<p>Tell us what you think about our web site, our products, our organization, or
anything else that comes to mind.<br> We welcome all of your comments and
suggestions.</p>
<FORM TARGET="<?php echo $PHP_SELF;?>" METHOD=POST>
<table>
<tr><td>Name:<? echo $error_msg;?><br>
<input type="text" size="35" maxlength="256" <? echo $name?> name="name" ></td>
</tr>
</table>
<input type="Submit" value="Submit_form">
<input type="reset" value="Clear Form">
</form></center><br>
</div>
<?
require ('footer1.inc')
?>
</body>
</html>
#########################
I do not have the function mail() put in the script yet it was giving me problems so i decided to try to fix this one item or a few at a time. at least I wanted to get the page to load with out parse errors
Please help me out to understand what I am doing wrong and where. The more I read the more confused I become I hope someday the clouds start to clear
Pat
baze
####################
Name:
Please fill in the email field
Please fill in a suggestion
E-Mail:
Please fill in the email field
Please fill in a suggestion
##########################
Its still not showing the $error_header though
Any other suggestions
Pat
<?
//Things fixed:
//Didn't have a name for the submit button
//changed form action value to $_SERVER["PHP_SELF"]
//needed to have 'value=' in "name" input tagif(isset($_POST['submit_btn'])) {
$error_msg = null;
# Default error_header
$error_header = "The following errors occured, Please rectify them before continuing<br>";
# error checking
if(!isset($_POST['name'])) {
$error_msg .= "Please Fill in the Name field<br>";
}
if(!$_POST['email']) {
$error_msg .= "Please fill in the email field<br>";
}
if(!$_POST['suggestion']) {
$error_msg .= "Please fill in a suggestion<br>";
}
# end error checking.
if(!$error_msg) {
# if everything ok,
# define variables from the posted data
header("Location: thankyou.php");
}
}
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="bluegrass.css">
</head>
<body>
<?php
include ('header1.inc');
?>
<div class="content">
<? if(isset($error_msg)) :?>
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2" align="center"><? echo $error_header?><br><? echo $error_msg;?></td>
</tr>
</table>
<? endif;?>
<center>
<p>Tell us what you think about our web site, our products, our organization, or
anything else that comes to mind.<br> We welcome all of your comments and
suggestions.</p>
<FORM action="<?php echo $_SERVER["PHP_SELF"];?>" METHOD=POST>
<table>
<tr><td>Name:<br>
<input type="text" size="35" maxlength="256" value="<? echo $_POST['name'];?>" name="name" ></td>
</tr>
</table>
<input name="submit_btn" type="submit" value="Submit_form">
<input type="reset" value="Clear Form">
</form></center><br>
</div>
<?
include ('footer1.inc')
?>
</body>
</html>
baze
<div class="content"><center>
<? if(isset($error_msg)) :?>
<table width="80%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2" align="center"><? echo $error_header?><br><? echo $error_msg;?></td>
</tr>
</table>
<? endif;?>
</center>
<center>
<p>Tell us what you think about our web site, our products, our organization, or
anything else that comes to mind.<br> We welcome all of your comments and
suggestions.</p>
<FORM action="<?php echo $_SERVER["PHP_SELF"];?>" METHOD=POST>
<p>What kind of comment would you like to send?</p>
<tr>
<td><input type="radio" name="messagetype" value="Complaint">Complaint <input type="radio" name="messagetype" value="Problem">Problem
<input type="radio" checked name="messagetype" value="Suggestion">Suggestion
<input type="radio" name="messagetype" value="Praise">Praise</td>
</tr>
<p>Please help us direct your feedback by selecting a catagory you would like to comment on?</p>
<tr>
<td><select name="department" size="1">
<option value="none">Select a Department</option>
<option value="Web Site">Web Site</option>
<option value="Company">Company</option>
<option value="Products">Products</option>
<option value="Artists">Artists</option>
<option value="Employee">Employee</option>
<option value="Customer_service">Customer Service</option>
</select></td>
</tr>
<p><? echo $error_msg;?></p>
<p>Enter your comments in the space provided below:</p>
<tr>
<td><textarea name="suggestion" value="<? echo $_POST['suggestion'];?>"rows="10" cols="42"></textarea></td>
</tr>
<p>Tell us how to get in touch with you:</p>
<table>
<tr><td>Name:<? echo $error_msg;?><br>
<input type="text" size="35" maxlength="256" value="<? echo $_POST['name'];?>" name="name" ></td>
</tr>
<tr>
<td>E-Mail:<? echo $error_msg;?><br>
<input type="text" size="35" maxlength="256" value="<? echo $_POST['email'];?>" name="email"></td>
</tr>
<tr><td>Telephone:<? echo $error_msg;?><br>
<input type="text" size="35" maxlength="256" value="<? echo $_POST['telephone'];?>" name="telephone"></td>
</tr>
<tr>
<td>Please contact me as soon as possible regarding this matter:
<td><input type="checkbox" name="contactrequested" value="1">
</tr>
</table>
<br>
<input name="submit_form" type="Submit" value="Submit_form">
<input type="reset" value="Clear Form">
</form></center><br>
</div>