Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. <style type="text/css">
    
    .bg1 {
    color:#000000;
    padding:1px;
    background-color:#FFFFFF;
    border:1px solid #000000;
    }
    
    .bg2 {
    color:#FFFFFF;
    padding:1px;
    background-color:#000000;
    }
    </style>
    
    <span class="bg1">Example of Number 1</span><p>
    <span class="bg2">Example of Number 2</span>
    

  2. <?php
    
    $day = date("j"); // 1-31
    $month = date("n"); // 1-12
    $year = date("Y");
    
    $sql = "SELECT * FROM `calendar` WHERE `day`='".$day."' AND `month`='".$month."' AND `year`='".$year."'";
    $res = mysql_query($sql) or die(mysql_error());
    
    if(mysql_num_rows($res) == 0){
    echo "Today is a boring day, nothing is happening!";
    }else {
    echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
    while($row = mysql_fetch_assoc($res)){
    	echo "<tr><td>".$row['event']."</td></tr>\n";
    }
    echo "</table>\n";
    }
    
    ?>
    

  3. <?php
    
    if(!$_POST['submit']){
    // form
    }else {
    $user = mysql_real_escape_string($_POST['username']);
    $pass = mysql_real_escape_string($_POST['password']);
    $errors = array();
    
    if(!$user){
    	$errors[] = "You did not supply a username";
    }else {
    
    	if(!in_array(strlen($user),range('3','32'))){
    		$errors[] = "Username must be between 3 and 32 characters";
    	}
    
    	if(!ctype_alnum($user)){
    		$errors[] = "Username can only contain alphanumerical characters";
    	}
    
    	$sql = "SELECT * FROM `users` WHERE `username`='".$user."'";
    	$res = mysql_query($sql) or die(mysql_error());
    	if(mysql_num_rows($res) == 0){
    		$errors[] = "The username already exists in the database";
    	}
    }
    
    if(!$pass){
    	$errors[] = "You did not supply a password";
    }else {
    	if(strlen($pass) < 6){
    		$errors[] = "Your password must be greater than or equal to 6";
    	}
    }
    
    if(count($errors) > 0){
    	echo "The following errors occurred:<br>\n";
    	foreach($errors AS $error){
    		echo $error . "<br>\n";
    	}
    }else {
    	$sql2 = "INSERT INTO `users` (`username`,`password`) VALUES('".$user."','".sha1($pass)."')";
    	$res2 = mysql_query($sql2) or die(mysql_error());
    	echo "You have successfully registered as ".$user."!\n";
    }
    }
    
    ?>
    

     

    give that a go.

  4. <?php
    
    for ($i = 1; $i <= 3; $i++) {
        $time = $_POST['time-' . $i];
    
        if ($time) {
            $scheduleinsert = "INSERT INTO `schedules` (`eventid`, `time`, `grades`, `room`, `notes`) VALUES ('" .
                $eventid . "', '" . $time . "', '" . $grades . "', '" . $room . "', '" . $notes .
                "')";
            $schedule_result = mysql_query($scheduleinsert);
        }
    }
    
    ?>
    

     

    Just make sure you have the other variables defined.

  5. <?php
    
    function BuyMS($user, $wal, $type)
    {
        $noNaquadah = "Not enough Naquadah!";
        $nosold = "Not enough untrained units!";
        if ($type == 0) {
            $pris = 350000000 * $wal;
            if ($pris <= ($user->gold)) {
                $q = @mysql_query("select Mothership from `UserDetails` where ID='$user->ID' ");
                $el = mysql_fetch_array($q, MYSQL_ASSOC);
                if ($el[] >= $wal) { // error on this line.
                    $q = @mysql_query("update `UserDetails` set Mothership = 1, gold=gold-'$pris' where ID='$user->ID' ");
                    if (!$q) {
                        print ('Query failed: ' . mysql_error());
                        return;
                    }
                } else
                    return $nosold;
            } else
                return $noNaquadah;
        }
    
        if ($cgi[buyMS]) {
    
            if ($cgi[Mothership]) {
                $wal = $cgi[Mothership];
                $typ = 0;
                $detail .= Mothership($user, $wal, $typ);
            }
        }
    }
    ?>
    

     

    since he's lazy.

  6. <input type="checkbox" name="name[]" value="1"><br>
    <input type="checkbox" name="name[]" value="2"><br>
    <input type="checkbox" name="name[]" value="3"><br>
    <input type="checkbox" name="name[]" value="4"><br>
    <input type="checkbox" name="name[]" value="5"><br>
    

     

    <?php
    $name = $_POST['name'];
    
    if(count($name) > 0){
    foreach($name AS $names){
    	echo $names . "<br>\n";
    }
    }else {
    echo "Please select one!\n";
    }
    ?>

  7. <?php
    
    $username = "marcus";
    
    $bad = array('fuck','ass','rape');
    
    foreach($bad AS $duh){
    if(preg_match("/$duh/is",$username)){
    	$err = 1;
    }
    }
    
    if($err){
    echo "Invalid username!\n";
    }else {
    echo "Nice username! -wink-\n";
    }
    

     

    With username -> marcus
    
    Nice username! -wink-
    

     

    With username -> marcusfuck
    
    Invalid username!
    

  8. Lol.

     

    php.net/ctype_alnum

     

    Alphanumeric characters.

     

    <?php
    
    $good = "ily";
    $bad = "ihy!";
    
    if(ctype_alnum($good)) echo "You win!\n"; else echo "You fail!\n";
    echo "<br>\n";
    if(!ctype_alnum($bad)) echo "You fail!\n"; else echo "You win!\n";
    
    ?>
    

  9. Ok, when the user views the haggling window that shows the item, the price and an input box to input their haggled price it sets the session "buy" to the value "yes." When the user submits their haggle it goes to the next part and all the security stuff, do they have enough points, is the haggle high or low enough, etc... If they pass all that they get the item and the session is destroyed. Before all the security stuff (when the form is submitted) it checks if the session exists, if it does, they can continue, but if it doesn't they tried to refresh and buy the item again. My problem is, the session is destroyed even before the user is able to buy the item.

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