Quantcast

Jump to content


Photo

Need help with HTML forms.


  • Please log in to reply
4 replies to this topic

#1 padora

padora
  • 991 posts

Posted 27 June 2010 - 07:44 PM

So I have...

An html page, guest.html
a php page, doit.php
a php page view.php

I want to go on the html page and type a name, "strname", an age "strage" and have it put those two inputs on the third page view.php.

how would i go about doing this. if im doing it the wrong way please correct me

#2 Noitidart

Noitidart
  • Neocodex Co-Founder

  • 23214 posts


Users Awards

Posted 27 June 2010 - 11:28 PM

Why have doit.php can't you just post it straight to view.php and it will show up there.

#3 Sweeney

Sweeney
  • 1230 posts


Users Awards

Posted 27 June 2010 - 11:35 PM

I'd just pass them as variables in the URL.
But I'm lazy ^_^

#4 Dan

Dan
  • Resident Know-It-All

  • 6382 posts


Users Awards

Posted 28 June 2010 - 01:57 AM

It's really dependent on what you'd like to do.

There are a 3 viable options:

  • Pass via querystring (ie doit.php?name=dan&password=password
  • Use a session variable (best for constants you need to reuse during X session)
  • Cookies (best for constants you need always - ie a keep-logged-in option)
For something as simple as you're doing, a querystring should be fine - it's easy to implement.

Make a request to your php page (doit.php) with the querystring added:
http://www.notaurl.codex/doit.php?name=dan&password=password


This then allows you to access said querystring in PHP like the following:
$username = $_GET['name'];
$password = $_GET['password'];

Easy.

#5 artificial

artificial
  • 186 posts


Users Awards

Posted 28 June 2010 - 02:36 AM

In which case your form method would be get. Other alternative is to post the data.

HTML
<form action="doit.php" method="post">
<input type="text" name="name" value="" />
<input type="submit" value="Submit" />
</form>


doit.php
<?php

$Name = $_POST['name'];
print "Name is: " . $Name;

?>

Edited by Artificial, 28 June 2010 - 02:37 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users