Jump to content
MakeWebGames

Need coding help quick


criminal wars

Recommended Posts

basically on register.php file there is some where, that you can pick a gender male or female

so i have made a new drop down menu where it say's starter gift

and the 2 options you can pick is

10 crystal's

$500 game cash

these are 2 gifts you can pick when signing up

but i need to put a coding in the file to make it work if anyone can give em a hand ....

Link to comment
Share on other sites

Surley after nick telling you exacally what you need to do, you would be able to do it. You cant even follow instructions

Not a drop down menu, he said a radiogroup.

Its a simple if statement.

Then edit the insert query on register.

Simple really.

Surley if your going to own a game you should either know how to code, have an in-house coder, or pay someone to do the work, and not just scav of other peoples good will.

Mabey these sites will help:

Site One and Site Two

  • Like 1
Link to comment
Share on other sites

<td width='30%'>Username</td>
<td width='40%'><input type=text class="other" size="12" name=username  onkeyup='CheckUsername(this.value);'></td>
<td width='30%'><div id='usernameresult'></div></td>


        <tr>
<td>Password</td>
<td><input type=password id='pw1' class="other" size="12" name=password onkeyup='CheckPasswords(this.value);PasswordMatch();'></td>
<td><div id='passwordresult'></div></td>
</tr>
<tr>


<tr>
<td>Confirm Password</td><td><input type=password class="other" size="12" name=cpassword id='pw2' onkeyup='PasswordMatch();'></td>
<td><div id='cpasswordresult'></div></td>
</tr>


<tr>
<td>Email</td><td><input type=text class="other" size="12"  name=email onkeyup='CheckEmail(this.value);'></td>
<td><div id='emailresult'></div></td>
</tr>   

<tr>
<td>Gender</td>
<td colspan='2'><select name='gender' type='dropdown'>
<option value='Male'>Male
<option value='Female'>Female</select></td>
</tr>     



<tr>   
<td>Starter Gift:</td>
<td><input type="radio" name="group1" value="10c"> 10 crystal's<br>
<input type="radio" name="group1" value="500cash" checked> $500 cash</td>
</tr>


             <tr>
               <td> </td>
             </tr>



             <tr>

               <td colspan="2" style="width: 150px;"> </td>
             </tr>

             <tr>
               <td style="width: 100px;"> </td>
               <td><input class="nor_but" type="submit" name="submit" value="" /></td>
             </tr>


             </table>
<center><a href='login.php'><u>Return to Login</u></a></center><br />



                                                       </form>

        </center>
<!-- Begin Main Content -->
EOF;
$IP = $_SERVER['REMOTE_ADDR'];
$IP=addslashes($IP);
$IP=mysql_real_escape_string($IP);
$IP=strip_tags($IP);
if(file_exists('ipbans/'.$IP))

{
die("<b><font color=red size=+1>Your IP has been banned, there is no way around this.</font></b></body></html>");
}

if($_POST['username'])
{
if($set['regcap_on'])
{
 if(!$_SESSION['captcha'] or $_SESSION['captcha'] != $_POST['captcha'])
 {
   unset($_SESSION['captcha']);
   die("<font style=color:red> Captcha Test Failed</font><br />
<a href='register.php'>>Back<</a>");
 }
 unset($_SESSION['captcha']);
}
if(!valid_email($_POST['email']))
{
die("<font style=color:red>Sorry, the email is invalid.</font><br />
<a href='register.php'>>Back<</a>");
}
if(strlen($_POST['username']) < 4)
{
die("<font style=color:red>Sorry, the username is too short.</font><br />
<a href='register.php'>>Back<</a>");
}
$sm=100;
if($_POST['promo'] == "")
{
$sm+=0;
}
$username=$_POST['username'];
$username=str_replace(array("<", ">"), array("<", ">"), $username);
$q=$db->query("SELECT * FROM users WHERE username='{$username}' OR login_name='{$username}'");
$q2=$db->query("SELECT * FROM users WHERE email='{$_POST['email']}'");
if($db->num_rows($q))
{
print "<font style=color:red>Username already in use. Choose another.</font><br />
<a href='register.php'>>Back<</a>";
}
else if($db->num_rows($q2))
{
print "<font style=color:red>E-Mail already in use. Choose another.</font><br />
<a href='register.php'>>Back<</a>";
}
else if($_POST['password'] != $_POST['cpassword'])
{
print "<font style=color:red>The passwords did not match, go back and try again.</font><br />
<a href='register.php'>>Back<</a>";
}









else
{

if($db->num_rows($q))
{
die("<font style=color:red>No creating referral multies. Bad dog.</font><br />
<a href='register.php'>>Back<</a>");
}

 

This is all you now can you check it out for me and fix what am talking about as you will see the gift are there but need the if states ment etc.. done for it to work

Edited by Dave Macaulay
Code tags added.
Link to comment
Share on other sites

I have not looked, but I take your word for it; that you have given it a go.

As said, set variables for amount of money/crystals you start with based on what the user selected. Basic if()

 

if ($_POST['bonus'] == 'cash') {
   $money = 500;
   $crystals = 10;
} else {
   $money = 200;
   $crystals = 50;
} 

 

As you said you have the button (not looked, but I take your word for it) All you need to really do at this point is make sure the insert query has the variables in it. How variables work in an insert is easy, the example is right there in the query you now need to edit, since username, password etc are all variables.

Edited by Dominion
Link to comment
Share on other sites

you are asking for easy stuff how you going to go run a game if you cant do this stuff try this

if ($_POST['group1']=='10c') {

$db->query("UPDATE `users` SET `crystals`=`crystals`+10 WHERE `userid`=".$i);

} else {

$db->query("UPDATE `users` SET `money`=`money`+500 WHERE `userid`=".$i);

}

not working? then try this

 

if ($_POST['group1']=='10c') {

$db->query("UPDATE users SET crystals=crystals+10 WHERE userid=".$i);

} else {

$db->query("UPDATE users SET money=money+500 WHERE userid=".$i);

}

Link to comment
Share on other sites

Sorry, the first one is actually correct, the later is just a n00bs way.....

 

you are asking for easy stuff how you going to go run a game if you cant do this stuff try this

surele then that means you wont be able to run a game, as $i isnt defined, as the user hasnt been created yet.

Link to comment
Share on other sites

you are asking for easy stuff how you going to go run a game if you cant do this stuff try this

if ($_POST['group1']=='10c') {

$db->query("UPDATE `users` SET `crystals`=`crystals`+10 WHERE `userid`=".$i);

} else {

$db->query("UPDATE `users` SET `money`=`money`+500 WHERE `userid`=".$i);

}

not working? then try this

 

if ($_POST['group1']=='10c') {

$db->query("UPDATE users SET crystals=crystals+10 WHERE userid=".$i);

} else {

$db->query("UPDATE users SET money=money+500 WHERE userid=".$i);

}

Why have extra queries when you can just edit the insert already being done? That, and what Danny said about $i ...

Link to comment
Share on other sites

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...