Jump to content

[SOLVED] Why isn't it working?


Zigster316

Recommended Posts

I am using a server that has MySQL v4.1 and my code is supposed to take data entered into an HTML for and insert it into a database. All that is happening though is that I am only having on field fill out and that is my person id which isn't retrieved from the form. Any ideas?! Here is the whole code(with php)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Form Output</title>
</head>

<body>
<?php include("header.php"); ?>
<?php 
$con=mysql_connect ("localhost", "prince_Prince", "password");//not real password for security
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  

$name = mysql_real_escape_string($_POST["name"]);
$gender = mysql_real_escape_string($_POST["gender"]);
$email = mysql_real_escape_string($_POST["email"]);
$comments = mysql_real_escape_string($_POST["comments"]);
mysql_query("INSERT INTO `emails` (`Name`, `Gender`, `Email`, `Comments`) VALUES ('$name', '$gender', '$email', '$comments')");

  mysql_close($con);
   ?> 
   <?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$age = $_REQUEST['age'];
$gender = $_REQUEST['gender'];
$comments = $_REQUEST['comments'];


$to = "[email protected]";
$subject = "$subject";
$message = "$name $email $gender $comments";
mail($to,$subject,$message);

echo "Thank you $name. I have now received an email containing the following information: <br/>
Name: $name <br/>
Email: $email <br/>
Email Subject: $subject <br/>
Age: $age <br/>
Gender: $gender <br/>
Comments: $comments";
?>
   <?php include ("footer.php"); ?>
</body>
</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/65633-solved-why-isnt-it-working/
Share on other sites

The form code is:

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

<fieldset><legend>Suggestions Form</legend>
<p><b>Name:</b><input type="text" name="name" maxlength="40"></p>
<p><b>Email:</b><input type="text" name="email" maxlength="60"></p>
<p><b>Email Subject:</b><input type="text" name ="subject" maxlength="40"></p>
<p><b>Gender:</b><input type="radio" name="gender" value="M">M <input type="radio" name="gender" value="F">F</p>
<p><b>Age:</b><select>
  <option value ="012">0-12</option>
  <option value ="1320">13-20</option>
  <option value ="2140">21-40</option>
  <option value ="4060">40-60</option>
  <option value ="61over">61+</option>
</select></p>
<p><b>Comments:</b><textarea name="comments" rows="5" cols="40"></textarea></fieldset>
<center><input type="submit" value="Submit">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.