Click to See Complete Forum and Search --> : [RESOLVED] extract function will not work?


webdev077
06-09-2007, 07:25 PM
Hello everyone:

I tried to use extract function to display value submitted from a form.

The output I got is '0000', which is not correct. I couldn't figure out what my problem is. Please help me find the cause. Thanks!

HTML form:


<head>
<title>extract data from form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>


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

Name: <input type="text" name="" size="20" maxlength="20"><br/><br />
Email: <input type="text" name="" size="20" maxlength="20"><br/><br />
Subject: <input type="text" name="" size="20" maxlength="20"><br/><br />
Text: <textarea name="text" cols="50" rows="10"></textarea><br/><br />

<input type="submit" name="submit" value="send" />
<input type="reset" name="reset" value="reset" />

</form>

</body>
</html>

PHP code that will process form data:


<?php

extract($_POST); //extract data from $_POST array

$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);

//mail the form information
$mail_to = "santa98bn@yahoo.com";
$from = "From: $name $email";

print ($name + "<br />");
echo ($email + "<br />");
echo ($subject + "<br />");
echo ($text + "<br />");

?>

webdev077
6-9-07

Sheldon
06-09-2007, 07:28 PM
none of your form fields have the name fields entered correctly.<head>
<title>extract data from form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>


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

Name: <input type="text" name="formname1" size="20" maxlength="20"><br/><br />
Email: <input type="text" name="formname2" size="20" maxlength="20"><br/><br />
Subject: <input type="text" name="formname3" size="20" maxlength="20"><br/><br />
Text: <textarea name="This was named" cols="50" rows="10"></textarea><br/><br />

<input type="submit" name="submit" value="send" />
<input type="reset" name="reset" value="reset" />

</form>

</body>
</html>

webdev077
06-11-2007, 01:18 AM
Hello Sheldon:

Thanks for pointing out my mistake. I added value for NAME attribute, now it's working!

webdev077

Sheldon
06-11-2007, 01:42 AM
Very Nice, I'm happy