Jump to content

putting all the data in one page


VikasSharma

Recommended Posts

please tell me about the error in this code and help me to resolve the error

 

 

 

<html>
<head>
<title>
using one page to accept and process data.
</title>
</head>
<body>
<h1>
using one page to accept and process data.
</h1> 
<?php
if (isset($_REQUEST ["flavour"]) ) {
echo "your favourite flavour is". $_REQUEST["flavour"] ;
}
?> 
<?php
if (isset($_REQUEST["name"] ) ) {
echo "your name is" . $_REQUEST["name"];
}
else {
?>
<form method = "post" action = "phpone.php">
what is your favourite ice cream flavor?
<input name = "flavor" type = "text">
<br>
<br>
what is your name?
<input type = "text" name = "name" >
<br>
<br>
<input type = submit value = submit >
</form>
<?php
}
?>
</body>
</html>

phpone1.php

Link to comment
Share on other sites

please use the code tags so it makes things easier for people to read.

 

i can see an error here:

if (isset($_REQUEST ["flavour"]) ) {
//<input name = "flavor" type = "text">

which should be

if (isset($_REQUEST["flavour"])) {
//<input name = "flavour" type = "text">

why don't you try something like this?

<html>
<head>
<title>
using one page to accept and process data.
</title>
</head>
<body>
<h1>
using one page to accept and process data.
</h1> 
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') 
{
    print_r($_POST);
}
else 
{
?>
	<form method="post">
		what is your favourite ice cream flavor?
		<input name = "flavor" type = "text">
		<br>
		<br>
		what is your name?
		<input type = "text" name = "name" >
		<br>
		<br>
		<input type = submit value = submit >
		</form>	
<?php
}
?>
</body>
</html>
Edited by Destramic
Link to comment
Share on other sites

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.