Trying out some things with php and html, I'm having issues trying to get all of my form data reposted. I've figured out how to do the text boxes. Still at a loss for the select box, radio and check box. Would I be better off reposting inside the HTML page or letting my include template code take care of it?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/rocks.css">
<title>About Us-- Rocks</title>
</head>
<body>
<?php include("templates/banner_navigation.php"); ?>
<div id="links_group">
<?php include("templates/menu.php"); ?> <!-- 1st include for navigation, stored in templates -->
</div>
<div id="about_us_form">
<?php include("templates/about_us_valid.php"); ?>
<form action="<?php echo $PHP_SELF;?>" method="post">
<table>
<tr><td>First name:</td><td><input type="text" name="contact_name" title="Enter your first name here" value="<?php if (isset($_POST['contact_name'])) echo $_POST['contact_name']; ?>" /></td></tr>
<tr><td>Email Address:</td><td><input type="text" name="contact_email" title="Enter your email here" value="<?php if (isset($_POST['contact_email'])) echo $_POST['contact_email']; ?>" ></td></tr>
<tr><td>Phone Number:</td><td><input type="text" name="contact_phone_number" title="555-555-5555" value="<?php if (isset($_POST['contact_phone_number'])) echo $_POST['contact_phone_number']; ?>" /></td></tr>
<tr><td>I prefer to be contacted by:</td><td><input type="radio" name="preference" value="Email" checked/>Email<input type="radio" name="preference" value="Phone" />Phone</td></tr>
<tr><td>I am interested in:</td> <td><select name="select_rocks"><option value="gold">Gold</option>
<option value="silver">Silver</option>
<option value="thorium" selected="selected">Thorium</option>
<option value="titanium">Titanium</option>
</select></td></tr>
<tr><td> I would like to ask about:</td></tr>
<tr><td><textarea name="that_textarea" rows ="10" cols="25" title="Enter your questions here!">
</textarea></td></tr>
<tr><td>I am also interested in:</td><td>
<tr><td>Gemstones <input type="checkbox" name="checkbox1[]" value="gemstones" /></td><tr>
<tr><td>Ore processing <input type="checkbox" name="checkbox1[]" value="oreprocessing" /></td></tr>
<tr><td><input type="hidden" name="checkbox1[]" value="" /> </td><tr>
<tr><td><input type="submit" value="submit" name="submitform" /></td></tr>
</table><br/>
</form>
</div>
</body>
the include template:
<?php
function check_for_cat($namecheck=false,$emailcheck=false){
if ($namecheck) $name_field_error = "(((Name Invalid!)))";
if ($emailcheck) $email_field_error = "(((Email Invalid!)))";
//Start of form
if($namecheck) echo "<tr><td>$name_field_error</td></tr>";
if($emailcheck) echo "<tr><td>$email_field_error</td></tr>";
}
if (!isset($_POST['submitform'])) {
check_for_cat();
} else {
$namecheck = false;
$emailcheck = false;
$contact_name = isset($_POST['contact_name']) ? trim($_POST['contact_name']) : '';
$contact_email = isset($_POST['contact_email']) ? trim($_POST['contact_email']) : '';
if (strlen($contact_name)<3) $namecheck = true;
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $contact_email)) $emailcheck=true;
if ($namecheck || $emailcheck ){
check_for_cat($namecheck,$emailcheck);
} else {
echo '(((OMG the form is submitted!)))';
}
}
?>
Its probably pretty easy to do, I've just been looking at the code for too long, Thanks for the help! If possible put some code up, google and yahoo haven't found me much to look at.