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

//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");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.