
01-06-2008, 21:44
|
|
|
|
חבר מתאריך: 17.05.05
הודעות: 7,321
|
|
מה עם החלק הבא:
קוד:
<html>
<body><form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form></body>
</html>
???
את צריכה לבנות טופס שישלח את הנתונים אל הקובץ welcome.php.
אבל, במקום ליצור 2 קבצים נפרדים, אפשר לעשות זאת בקובץ אחד בלבד:
קוד PHP:
<html>
<body>
<?php
if (isset($_POST['name']))
{
?>
Welcome <?php echo $_POST['name']; ?>.<br />
You are <?php echo $_POST['age']; ?> years old.
<?php
}
else
{
?>
<form action="" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
<?php
}
?>
</body>
</html>
|