Jump to content
MakeWebGames

Recommended Posts

Posted

can anyone please help me with this function i tryed playing around with it but its no use i cant get it to stop user having same names and also users can get invisible name by using space bar

 

 function gang_staff_name()
{
global $db, $ir, $userid, $gangdata, $h, $leaders;
if(in_array($userid, $leaders))
{
if(isset($_POST['subm']))
{
$_POST['subm'] = trim($_POST['subm']);
$check=$db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE `gangNAME` = '%s'", clean($_POST['subm'])));
$checking=$db->query($check)
if($db->num_rows == 1))
{
print "ERROR.

[url='yourgang.php?action=staff']> Back[/url]";
$h->endpage();
exit;
}
$sql = sprintf("UPDATE gangs SET gangNAME = '%s' WHERE (gangID = %u)", clean($_POST['vp']), $gangdata['gangID']);
$db->query($sql);
echo "Gang name changed!

[url='yourgang.php?action=staff']> Back[/url]";
}
else
{
echo "Current Name: 
";
echo sprintf("%s
", format($gangdata['gangNAME']));
echo "
<form action='yourgang.php?action=staff&act2=name' method='post'>";
echo "<input type='hidden' name='subm' value='submit' />";
echo "<table class='table' width='75%'>";
echo "<tr>";
echo "<th>New name</th>";
echo sprintf("<td style='text-align:center;'><input type='text' name='vp' value='%s' size='40%%' /></td>", format($gangdata['gangNAME']));
echo "</tr>";
echo "<tr>";
echo "<td colspan='2' style='text-align:center;'><input type='submit' value='Change' /></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
}
}
Posted

Re: gang-staff-function

How about this?

 

function gang_staff_name()
{
global $db, $ir, $userid, $gangdata, $h, $leaders;
if(in_array($userid, $leaders))
{
if(isset($_POST['subm']))
{
$_POST['subm'] = trim($_POST['subm']);
$check=$db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE `gangNAME` = '%s'", clean($_POST['vp'])));
$checking=$db->query($check)
if($db->num_rows == 1))
{
print "ERROR.

[url='yourgang.php?action=staff']> Back[/url]";
}
else if(strlen($_POST['vp']) < 8) {
print "Your gang name must be at least 8 characters";
}
else if(eregi('[^0-9a-z]', $_POST['vp'])) {
print "Invalid name.";
}
else
{
$sql = sprintf("UPDATE gangs SET gangNAME = '%s' WHERE (gangID = %u)", clean($_POST['vp']), $gangdata['gangID']);
$db->query($sql);
echo "Gang name changed!

[url='yourgang.php?action=staff']> Back[/url]";
}
}
else
{
echo "Current Name: 
";
echo sprintf("%s
", format($gangdata['gangNAME']));
echo "
<form action='yourgang.php?action=staff&act2=name' method='post'>";
echo "<input type='hidden' name='subm' value='submit' />";
echo "<table class='table' width='75%'>";
echo "<tr>";
echo "<th>New name</th>";
echo sprintf("<td style='text-align:center;'><input type='text' name='vp' value='%s' size='40%%' /></td>", format($gangdata['gangNAME']));
echo "</tr>";
echo "<tr>";
echo "<td colspan='2' style='text-align:center;'><input type='submit' value='Change' /></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
}
}
Posted

Re: gang-staff-function

work perfect thank you so much richard +3 mate and it gave me a head ache from all the thinking i was doing to fix it and now i know how it works thank to you

Posted

Re: gang-staff-function

i was testing this and come up with a few errors

have sorted a few like a missing ; and one to many ). but now its coming up with

Warning: in_array() [function.in-array]: Wrong datatype for second argument

here is the updates so far down to that error

function gang_staff_name()
{
global $db, $ir, $userid, $gangdata, $h, $leaders;
if(in_array($userid, $leaders))
{
if(isset($_POST['subm']))
{
$_POST['subm'] = trim($_POST['subm']);
$check=$db->query(sprintf("SELECT `gangNAME` FROM `gangs` WHERE `gangNAME` = '%s'", clean($_POST['vp'])));
$checking=$db->query($check);
if($db->num_rows == 1)
{
print "ERROR.

[url='yourgang.php?action=staff']> Back[/url]";
}
else if(strlen($_POST['vp']) < 8) {
print "Your gang name must be at least 8 characters";
}
else if(eregi('[^0-9a-z]', $_POST['vp'])) {
print "Invalid name.";
}
else
{
$sql = sprintf("UPDATE gangs SET gangNAME = '%s' WHERE (gangID = %u)", clean($_POST['vp']), $gangdata['gangID']);
$db->query($sql);
echo sprintf("Crew name changed to %s.
", htmlentities($_POST['vp']));
echo "[url='yourgang.php?action=staff']> Back[/url]";
}
}
else
{
echo "Current Name: 
";
echo sprintf("%s
", format($gangdata['gangNAME']));
echo "
<form action='yourgang.php?action=staff&act2=name' method='post'>";
echo "<input type='hidden' name='subm' value='submit' />";
echo "<table class='table' width='75%'>";
echo "<tr>";
echo "<th>New name</th>";
echo sprintf("<td style='text-align:center;'><input type='text' name='vp' value='%s' size='40%%' /></td>", format($gangdata['gangNAME']));
echo "</tr>";
echo "<tr>";
echo "<td colspan='2' style='text-align:center;'><input type='submit' value='Change' /></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
}
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...