0

Can anyone help me i need to make it so that my customers can click a button and it will preform this mysql query *UPDATE Users SET groupid = 'P' WHERE userid = '$id';* and then re-direct them to a specific page.

Thanks

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by anuspan
0

//this is your main page

<html>
<body>
<form action="test.php" method="post">
<input type="submit">
</form>
</body>
</html>

//test.php code goes here

<?php
mysql_connect("your_server_name","your_user_name","your_password") or die("could not  connect to the database");
mysql_select_db("your_database_name") or die("database not exists");
mysql_query("UPDATE Users SET groupid = 'P' WHERE userid = '$id' ") or die("can not execute the query");

//im redirecting page to "example.htm"
header("location:example.htm");
?>

this exaple shows that your query executes when you click on the submit buttons.if you want to pass data from main page to test.php you have to use aditional <input tags>.
ex: <input type="text" id="username" name="username"> then you can access to that data by using following syntax in test.php, $user = $_POST['username']; //connect db here mysql_query("UPDATE Users SET groupid = 'P' WHERE [U]username = '$user'[/U] ") or die("can not execute the query");

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.