Jump to content

Problem with simple script


dean7

Recommended Posts

Hi all, Im coding a simple script for my website which just changes the users rank.

 

<?php
session_start();
include "../includes/db_connect.php";
include "../includes/functions.php";
logincheck();

ini_set ('display_errors', 1);
error_reporting (E_ALL);

$username=$_SESSION['username'];

$get = mysql_query ("SELECT * FROM users WHERE username = '$username'");
$fetch = mysql_fetch_object($get);

if ($fetch->userlevel >= "2"){		
$newrank = $_POST['newrank'];
$user1 = $_POST['user'];
if (strip_tags($_POST['update'])){	
mysql_query("UPDATE users SET `rank` = '$newrank' WHERE username='$user1'") or die (mysql_error());
echo ("You have updated $user1's rank to $newrank !");
}
}
else{
echo ("Your userlevel isnt high enouth to be here!");
}
?>
<html>
<head>
<title>Change Rank</title>
<link rel="stylesheet" href="../includes/in.css" type="text/css">
<style type="text/css">
.infobg {
font-family: Arial;
font-weight:normal;
font-size:12px;
border-top: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
border-left: 1px solid #000000;
background: URL(textbg1.png);
font-weight:300;
}

.button {
font-size: 12px;
background:url(button.png);
vertical-align: middle;
border-top: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
border-left: 1px solid #000000;
color: #FFFFCC;
height:23px;
font-weight:300;
border-radius: 10px;
padding-bottom:2px;
}

</style>
</head>
<body>
<form action='' method='post' name='form1'>
<table width='30%' cellpadding='0' align='center' cellspacing='0' border='1' bordercolor='#000000' bgcolor='#808080' style='border-collapse: collapse'>
<tr>
	<td background='../header.jpg' colspan='2' align='center'>Change Rank</td>
<tr>
	<td>Username:</td><td><input type='text' name='user'></td>
</tr>
<tr>
	<td>Rank:</td><td><input type='text' name='newrank'></td>
</tr>
<tr>
	<td> </td><td><input type="submit" name="update" value="Update Rank"></td>
</tr>
</form>	
</table>
</body>
</html>

But there seems to be something wrong with that code, which I carnt see or work out. When I click Update submit button it does nothing, but can anyone see why it does nothing?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/211972-problem-with-simple-script/
Share on other sites

is the $_SESSION['username'] working....

 

there no code mistake..

 

unless you add

<?php

if($_POST['update']){

//all the code here to update the database.......
}
?>

 

Dont see nothing else wrong , is all the variable names correctly spell in the database have a look?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.