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