[PHP] use web hyperlink to insert data into MySQL?

2003-04-01 Thread Levi Zander
I am trying to use PHP to create a hyperlink button that writes data to
MySQL database and sends the user to a new page.. is this possible?  if so
would you post the syntax/site where I can find out how to do this... thx!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] use web hyperlink to insert data into MySQL?

2003-04-01 Thread Hugh Danaher
Levi,
Very easy to do exactly what you want using php
1. write your link to a php page (described below) which includes the items
you want stored appended to the link a
href=page.php?var1=somethingvar2=something_elsego to next page/a
2. create a php page which contains the following:
?php
$var1=$_GET['var1']; // converts $_GET[] var to something easier to type
; )
$var2=$_GET['var2'];
'evaluate var1 and var2 with conditional statements'
'open your mysql database' // you'll need to put your code here
$result=mysql_query(insert into table_name (var1, var2) values
('$var1', '$var2') ); // stores data
mysql_close($link);
header(location: another_page.htm);  // sends user to your next page.
php?

Easy enough, but you'll need a form if you want user supplied info.  Also,
since the appended data could be altered before sent, this method is not
secure from tampering.  You'll need to evaluate the input to determine that
it's what you expect.
Hugh


- Original Message -
From: Levi Zander [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 12:21 PM
Subject: [PHP] use web hyperlink to insert data into MySQL?


 I am trying to use PHP to create a hyperlink button that writes data to
 MySQL database and sends the user to a new page.. is this possible?  if so
 would you post the syntax/site where I can find out how to do this... thx!



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] use web hyperlink to insert data into MySQL?

2003-04-01 Thread John W. Holmes
 I am trying to use PHP to create a hyperlink button that writes data
to
 MySQL database and sends the user to a new page.. is this possible?
if so
 would you post the syntax/site where I can find out how to do this...
thx!

Do you want a hyperlink or a button? You can't have both. Whether you
add data on to a URL in a link such as example.php?var=1foo=bar or use
a form with method=GET, the data appears in example.php in the $_GET
array. Parse and validate the values in that array and then insert it
into the database. You can find any PHP/MySQL tutorial to tell you how
to do that. 

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php