FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Don't know what's wrong





ncwdavid
Hey, I am practicing some php I have just learned and it is a simple form but I don't want to save it into a database yet. Here is the code for test.html and test.php. Could someone please tell me whats wrong?

test.html
Quote:
<html>
<head>
<title>Register To Recieve Your Free iPod Nano</title>
</head>
<body>
<h3 align="center">Please Register</h3>
<p>You must register in order to recieve your free ipod nano!</p>
<p>Titles with a (*) are required</p>
<form action="test.php" method="post">
<p>First Name:<br><input type="text" name="frstnm"></input></p>
<p>Last Name:<br><input type="text" name="lstnm"></input></p>
<p>Email Address:<br><input type="text" name="mldrs"
<p>Address:<br><input type="text" name="adrs1"></input></p>
<p>Town/City:<br><input type="text" name="adrs2"></input></p>
<p>State:<br><input type="text name="adrs3"></input></p>
<p>Postal Code:<br><input type="text" name"adrs4"></input></p>
<p>Country:<br><input type="text" name"adrs5"></input></p>
<input type="submit" value="Submit"></input>
<input type="reset" value="Clear"></input>
</form>
</body>
</html>


test.php
Quote:
<html>
<head>
<title>Thank You For Registering</title>
</head>
<body>
<?php
$frsnm = $_POST['frsnm'];
$lstnm = $_POST['lstmn'];
?>
<h2 align="center">Thank You For Registering<?php echo $frsnm.$lstnm; ?>!</h2>
<p><?php echo $frsnm; ?> your free ipod will be on its way to your doorstep tommorro.
</body>
</html>


When I click "Submit" in the test.html it brings me to test.php but it only says:
Quote:
Thank You For Register
your free ipod will be on its way to your doorstep tomoro.


but I want it to say:
Quote:
Thank You For Registering (firstname) (lastname)
(firstname) your free ipod will be on its way to your doorstep tomoro
mathiaus
The _POST vars are named exactly as the names of the inputs (you spelled them wrong).

Code:
$frsnm = $_POST['frstnm'];
$lstnm = $_POST['lstnm'];


In future you can check their values by using this code to show all the stored data in post
Code:
var_dump($_POST);
hexkid
You might want to increase the reporting level of PHP.

Try adding these lines to the very top of your scripts
Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>


If you had these lines in your test.php script the output would be
Quote:
Notice: Undefined index: frsnm in test.php on line 7
Notice: Undefined index: lstmn in test.php on line 8
Thank You For Register
your free ipod will be on its way to your doorstep tomoro.
Related topics
Ok a little help for a semi-beginner
Optimization is spelled wrong
Wrong number leads to drug arrest
Is the death penalty wrong?
What is wrong with FTP???
Date wrong on pc
Something wrong with signatures
waht is wrong with muslims???
Give me a HOLLA if you are a fervent agnostic!
Make me a riddle-for 50 Frih$ (Closed - winners announced!)
Somethin is wrong with my account
Email from Yahoo! and AOL will be CHARGED
Why scream NOTHING when SOMETHING is obversely wrong????
Are one night stand's wrong?
parking a domain on server 2 using directAdmin
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.