View Single Post
 
Old July 9th, 2006, 07:22 PM
PHP Newb PHP Newb is offline
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code chapter 5 pg 145-146

When I typed all of the cose for form3.php and formprocess.php and entered the information in the book, I press Submit and I dont get the page, what I get is a URL http://form3.php/formprocess3.php. Now if I save the form3 as an html file it works flawlessly am I doing something wrong? Here is the code for both

Form3.php
<html>
<head>
<title>Add/Search Entry</title>
<style type="text/css">
TD{color:#353535;font-family:verdana}
TH{color:#FFFFFF;font-family:verdana;background-color:#336699}
</style>
</head>
<body>
<form action="formprocess3.php" method="post">
<table border="0" cellspacing="1" cellpadding="3"
       bgcolor="#353535" align="center">
  <tr>
    <td bgcolor="#FFFFFF" width="50%">Name</td>
    <td bgcolor="#FFFFFF" width="50%">
      <input type="text" name="Name">
    </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">What you are looking for</td>
    <td bgcolor="#FFFFFF">
      <select name="MovieType">
        <option value="" selected>Select a movie type...</option>
        <option value="Action">Action</option>
        <option value="Drama">Drama</option>
        <option value="Comedy">Comedy</option>
        <option value="Sci-Fi">Sci-Fi</option>
        <option value="War">War</option>
        <option value="Other">Other...</option>
      </select>
    </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">Add what?</td>
    <td bgcolor="#FFFFFF">
      <input type="radio" name="type" value="Movie" checked>
      Movie<br>
      <input type="radio" name="type" value="Actor">
      Actor<br>
      <input type="radio" name="type" value="Director">
      Director<br>
    </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF" width="50%">Display Debug info</td>
    <td bgcolor="#FFFFFF" width="50%">
      <input type="checkbox" name="Debug" checked>
    </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF" colspan=2 align="center">
      <input type="submit" name="Submit" value="Search">
      <input type="submit" name="Submit" value="Add">
    </td>
  </tr>
</table>
</form>
</body>
</html>

formprocess3.php
<?php
if ($_POST['type'] == "Movie" && $_POST['MovieType'] == "") {
  header("Location:form3.php");
}
$title = $_POST['Submit'] . " " .
         $_POST['type'] . " : " .
         $_POST['Name'];
?>
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<?php
  if ($_POST['Debug'] == "on") {
?>
<pre>
<?php
    print_r($_POST);
?>
</pre>
<?php
  }
  $name = $_POST['Name'];
  $name[0] = strtoupper($name[0]);
  if ($_POST['type'] == "Movie") {
    $foo = $_POST['MovieType'] . " " . $_POST['type'];
  } else {
    $foo = $_POST['type'];
  }
?>

<p align="center">
  You are <?php echo $_POST['Submit']; ?>ing
  <?php echo $_POST['Submit'] == "Search" ? "for " : ""; ?>
  a <?php echo $foo; ?>
  named "<?php echo $name; ?>"
</p>
</body>
</html>

I'm getting kinda code