Forum Moderators: coopster
HTML:
<!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=utf-8" />
<title>Simple Html form</title>
</head>
<body>
<form action="handle_form.php" method="post">
<fieldset><legend>Enter your information in the form below:</legend>
<p><b>Name:</b><input type="text" name="name" id="name" size="20" maxlength="40" /></p>
<p><b>Email Adress:</b> <input type="text" name="email" id="name" size="40" maxlength="60" /></p>
<p><b>Gender:</b><input type="radio" name="gender" id="gender" value="M" />Male<input type="radio" name="gender" id="gender" value="F" />Female</p>
<p><b>Age:</b><select name="age">
<option value="0-29">Under 30</option>
<option value="30-60">Betwen 30 and 60</option>
<option value="60+">Over 60</option></select></p>
<p><b>Comments:</b><textarea name="comments" id="comments" rows="3" cols="40"></textarea></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit my information" /></div>
</form>
</body>
</html>
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=utf-8" />
<title>Handle form</title>
</head>
<body>
<?php
//Creaza o forma prescurtata pentru datele din formular.
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$comments = $_REQUEST['comments'];
//Nefolositeage, gender, submit
//Afiseaza informatiile transmise.
echo "<p>Thank you, <b>" . $name . "</b>, for the following comments:<br /><tt>" . $comments . "</tt></p><p>We will reply to you at <i>" . $email . "</i>.</p>";
?>
</body>
</html>
My problem that after I complete this html form it's appearing this(without dates from my form) :
Thank you, " . $name . ", for the following comments:
" . $comments . "
We will reply to you at " . $email . ".
"; ?>
I'm using wamp. Do you know what's the problem, please?
Thank you
with
echo "<p>Thank you, <b>$name</b>, for the following comments:<br /><tt>$comments</tt></p><p>We will reply to you at <i>$email</i>.</p>";
<p><b>Name:</b><input type="text" name="name" id="name" size="20" maxlength="40" /></p>
<p><b>Email Adress:</b> <input type="text" name="email" id="name" size="40" maxlength="60" /></p>
You cannot have two IDs with the same value, I suspect the second should be
id="email"?
Apart from this, do your pages validate [validator.w3.org]?
Are you getting any PHP errors? Do you have full error_reporting On? ie. At the start of your script:
ini_set('display_errors','On');
error_reporting(E_ALL ¦ E_STRICT); The output you are getting is like you have a mismatch of quotes or you are using single quotes to delimit the entire string?! But the code you have posted appears OK.
In dreamweaver cs 4 I have some errors:
Notice: Undefined index: name in C:\wamp\www\php\handle_form.php on line 12
Notice: Undefined index: email in C:\wamp\www\php\handle_form.php on line 13
Notice: Undefined index: comments in C:\wamp\www\php\handle_form.php on line 14
Thank you, $name, for the following comments:
$comments
We will reply to you at $email.
I think all quotes are ok...entire the page source is up(on my first post)....so is the same
Notice: Undefined index: name in C:\wamp\www\php\handle_form.php on line 12
It does not appear that your FORM fields are being passed back to your handle_form.php script. What version of PHP are you using?
Try outputing the contents of $_REQUEST to see what it contains...
print_r($_REQUEST);
Strictly speaking you should be using the $_POST array instead of $_REQUEST, since it will be more secure, but $_REQUEST should still work.
Are you testing this within the dreamweaver environment? Or in a separate browser on the webserver? I would have expected different output if the later?!
...but I guess that I must to configure the server and I don't....so...I'm stuck.
You shouldn't have to configure the server to get this to work. This should work on any configuration, so there must be something fundamentally wrong somewhere.
As suggested above, what do you get if you output the contents of $_REQUEST ?
Does phpinfo() produce the expected output?
We will reply to you at " . $email . ".
"; ?>
The code source is this:
<!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=utf-8" />
<title>Handle form</title>
</head>
<body>
<?php
echo '<pre>';
print_r($_REQUEST);
echo '</pre>';
?>
<?php
//Creaza o forma prescurtata pentru datele din formular.
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$comments = $_REQUEST['comments'];
//Nefolosit eage, gender, submit
//Afiseaza informatiile transmise.
echo "<p>Thank you, <b>" . $name . "</b>, for the following comments:<br /><tt>" . $comments . "</tt></p><p>We will reply to you at <i>" . $email . "</i>.</p>";
?>
</body>
</html>
I feel like crazy
Thank you, ryhrtyh, for the following comments:
fghfgh
We will reply to you at tyhrt.
www/form.html (http://localhost/form.html)
www/handle_form.php (http://localhost/handle_form.php)
dc
Is not something about my settings or extensions? I repeat that I created others php files and everything was ok
jatar_k: so then it looks like the php isn't getting parsed...
Yes, as jatar_k suggests in the 3rd post, the output you are getting is as if the PHP is not getting parsed at all! As if you are accessing your files outside of your webserver (as dreamcatcher suggests). Is your webserver (ie. Apache) running?
However, you say, "yes, other works...", which would imply PHP IS getting parsed in other files? And to get notice/warnings such as:
Notice: Undefined index: name in C:\wamp\www\php\handle_form.php on line 12
Notice: Undefined index: email in C:\wamp\www\php\handle_form.php on line 13
Notice: Undefined index: comments in C:\wamp\www\php\handle_form.php on line 14
<?php phpinfo(); ?>
Navigate to this file in your browser ie. "http://localhost/phpinfo.php" or wherever the file is located. What output do you get? If PHP/webserver is working then you should see several pages of PHP configuration settings.
(Delete this file when you are finished with it.)
I created this:<?php phpinfo(); ?>...and I sow a white page.
But on the [localhost...] I have a PHP menu ->on the Tools menu I have phpinfo(). When I click on this I can see several pages about PHP, extensions, etc.
Welcome to phpMyAdmin
Error
MySQL said: Documentation
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
I created this:<?php phpinfo(); ?>...and I sow a white page.
If you see a white/blank page then the PHP is not being processed. What URL are you using to access this page (phpinfo.php) ?
But on the [localhost...] I have a PHP menu ->on the Tools menu I have phpinfo(). When I click on this I can see several pages about PHP, extensions, etc.
That sounds like the WAMP control panel? If this works, then your phpinfo.php should also work. As dreamcatcher suggests, it does sound like your files are in the wrong place, but other things you say seem to suggest they are OK?
When you view the PHPInfo (via the WAMP control panel) what does it give for the value of DOCUMENT_ROOT ?