Jump to content

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 = "ziggy6005@gmail.com";
$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">

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.