Re[2]: [PHP] Form
| From: | David Tod Sigafoos | Date: | Tue, 12 Dec 2000 20:28:18 +0000 |
| Subject: | Re[2]: [PHP] Form | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29950@lists.php.net to get a copy of this message | ||
MG> I think that you need to use php to write javascript code and access to
MG> form elements...
No java script needed ..
Murat ..
This example uses mysql but it should be similar to oracle ..
Just remember .. your 'username' needs to be a single instance. Here
I only read the first row fetched no matter how many rows there are.
This could be simply changed to use a table to display returns.
Hope this helps .. simply cut out and past into php file. Make oracle
changes, changes to the row element where data is found AND use your
dbhost - dbuser - dbpass.
<?php
/*
if we are coming into the form and 'submit' is set then we are responding
to our press of 'press me'. We want to get the 'name' and then search
the
db for our surname and insurance.
*/
// username has something in it we must have hit the old submit button
if (isset($username)) {
$dbconnect = mysql_connect($DBHOST, $DBUSER, DBPASS);
// check that we have the connection or die a violent death
if (!$dbconnect)
die("No database connection");
// generate a search based on what is in the username field
$searchString = "select * from users where user_id='$username'";
// remove the die method for real life .. might just want to test and return
$result_id = mysql_query($searchString)
or die(mysql_error());
// get the row we are dealing with ..
$row = mysql_fetch_row($result_id);
// set the vars to what is is the array element of ROW
$surname=$row[4];
$insurance=$row[2];
} else {
// if it is not set set the vars to null ..
$username = '';
$surname = '';
$insurance = '';
}
?>
<html>
<head>
<title>Test Single PHP Input and Submit</title>
</head>
<body bgcolor="#ffffff">
<table bgcolor=#000000 valign=top align=center border=0>
<tr>
<td bgcolor=#000000>
<table cellpadding=4 bgcolor=#ffffff cellspacing=2 border=0>
<Tr><th>Add a User</th></tr>
<tr>
<td>
<FORM METHOD="get" ACTION=<?php echo("$PHP_SELF"); ?>>
Username: <INPUT TYPE=text MAXLENGTH=20 NAME="username" VALUE="<?php
echo($username); ?>" SIZE=20><Br>
Surname: <Input Type=text Maxlength=20 Name="userpass" VALUE="<?php
echo($surname); ?>" Size=10><Br>
Insurance:<Input Type=text Maxlength=20 Name="password" VALUE="<?php
echo($insurance); ?>" Size=20><br>
<INPUT TYPE=submit VALUE="submit">
</form>
</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
--
DSig
David Tod Sigafoos
mailto:dsig@teleport.com
Using 'The Bat' 1.48 Beta/11
`````
( O O )
_______oOOo__( )__oOOo_______