Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. Deh, dark, you should help him out by stopping out a mysql injection.

     

    $id = mysql_real_escape_string($_GET['category_id']);
    
    if($id){
       if(ctype_digit($id)){ //if you don't have ctype extension on use intval
       $sql = "SELECT * FROM `table` WHERE `id`='$id'";
       $res = mysql_query($sql) or die(mysql_error());
          if(mysql_num_rows($res) == 0){
          echo "ID does not exist!\n";
          }else {
          $sql2 = "UPDATE `table` SET `field`='new_row' WHERE `id`='$id'";
          $res2 = mysql_query($sql2) or die(mysql_error());
          echo "Updated";
          }
       }else {
       echo "Invalid ID";
       }
    }else {
    echo "ID not set";
    }
    

  2. Just define the variables that correspond with your form field names.

     

    $name = $_POST['form_field_name_one']; //etc....

     

    To see if a value exists just implement the 5th and 6th of my example to fit your own.

     

    If you have more than two just continue adding sets of line five and six to meet your requirements

  3. $var = $_POST['variable'];
    $var2 = $_POST['variable2'];
    $errors = array();
    
    if(!$var){ $errors[] = "Var one is missing!"; }
    if(!$var2){ $errors[] = "Var two is missing!"; }
    
    if(count($errors) > 0){
       foreach($errors AS $error){
       echo "<font color=\"red\">$error</font><br>\n";
       }
    }else {
    echo "both variables are set, you're ready for take off!\n";
    }
    

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