Jump to content

php communication


dan_t

Recommended Posts

Hi,

Somehow I lost my last post. I took a class last year on php where we worked with a form. we did it so fast that I never really understood what we did. My question is how do I get my input from the text box in the form to an if - else statement? here is a small example:

<html>

<head>

<title>Forms!!</title>

</head>

<body bgcolor="#cccccc">

 

<?php

 

if ($_GET['form.php']) {

  echo ('data = '.($_GET["name"]));

 

 

}

?>

 

<form action="form.php" method="get">

<p>This is to be sent:<input type="text" name="value" /></p>

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

<input type="reset" name="reset" value="redo" />

 

 

</form>

</body>

</html>

 

 

I used the get method so I could view it in the browser.

It says value= whatever I type in, but how do I grab it?

Please help me understand, if you wouldn't mind.

Thanks

Dan

Link to comment
https://forums.phpfreaks.com/topic/144385-php-communication/
Share on other sites

Given this form....

 

<form action="form.php" method="get">
<p>What is your favourite color?<input type="text" name="color" /></p>
<input type="submit" name="submit" value="send" />
<input type="reset" name="reset" value="redo" />

 

</form>

 

<?php

if (isset($_GET['submit'])) {
  if ($_GET['color'] == 'blue') {
    echo "good job";
  } else {
    echo "Try again";
  }
}

 

ps: You might want to start with the Hudzilla link in my signiture, this is very basic stuff.

?>

Link to comment
https://forums.phpfreaks.com/topic/144385-php-communication/#findComment-757660
Share on other sites

Thank you very much for your help.

On your first answer, why wouldn't you get the form name (form.php or whatever) instead of the "submit" name?

Thanks

and thanks for the link, I have read quite a bit.

It kind of puts some of the pieces together.

We blew by alot of the stuff in that class so fast that I never really understood what or why we were doing certain things.

I'm finally after a year starting to understand (a little).

Dan

Link to comment
https://forums.phpfreaks.com/topic/144385-php-communication/#findComment-759226
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.