how can I write a php code to from HTML form to send parameters to web server
Sending form data to PHP
Collapse
X
-
Originally posted by amrsorhow can I write a php code to from HTML form to send parameters to web server
1. Forms - The main way to get user data into your scripts is by the use of HTML forms. Forms have one of two actions, GET and POST. POST sends the data in the forms behind the scenes, while GET adds the data to the URL of the accepting page.
EX: [HTML]<form action='myphpsc ript.php' method='post'>
<form action='myphpsc ript.php' method='get'>[/HTML] You then access the post values in your action script using the POST / GET array. Like this: [PHP]<?=$_POST['fieldname']; ?>
<?=$_GET['fieldname']; ?>[/PHP] which would echo out the field value.
2. Sessions - You can set session variable using the $_SESSION super global.
EX: [PHP]<? $_SESSION['fname']='bob'; ?> [/PHP] which sets a session variable of fname with a value of bob. Remember you must use a [PHP]session_start()[/PHP] at the top of every page in which you want to access session variables.
Hope that helps!
GregLast edited by pbmods; Aug 21 '07, 04:00 AM. Reason: Remove edit reason. Sorry, G. Not safe for kids.
Comment