Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Posts posted by Wolphie

  1. What is the code for the password function? If I were you, I would just use:

     

    <?php
      $password = 'mycoolPA55w0rd';
      
      $con = mysql_connect(...);
      mysql_select_db(...);
      $query = sprintf("SELECT * FROM `login` WHERE `uname` = '%s' AND `pass` = '%s' LIMIT 1", 
        sha1($password)); // Need code for password()!!
      $result = mysql_query($query) or trigger_error(mysql_error());
    ?>
    

  2. You would need to submit the form to itself, or use JavaScript and Ajax.

     

    Simple normal example:

    <?php
    if(isset($_POST['submit'])) {
      if(empty($_POST['name'])) {
        print 'Please enter a name!';
      }
    }
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
      <input type="text" name="name" />
      <input type="submit" name="submit" />
    </form>
    

  3. <?php function check_phone_number($cellphone) {
    
    if(trim($cellphone) == 10) { return true;  }
    
    else {  return false; }
    
    }
    ?>
    

     

    This will make sure that the phone number has to be 10 characters. The trim function removes any white spaces...

     

    Sorry i can not do this for you using regular expressions but im sure someone else could if you ask

     

    This wouldn't check to see if the phnone number is 10 characters, it would check to see if it was equal to 10.

     

    if(strlen(trim($cellphone)) == 10) { return true; }
    

     

  4. Basically, regular expressions are used to detect certain characters/tags in text and gets the value in between them. Depending on which tag is used, the HTML is appropriately formatted. This also helps prevent XSS, and Injections too, by not allowing the user to directly enter HTML tags.

  5. Please use the Code BB tags in future. But the answer to your question is to submit the form to itself using $_SERVER['PHP_SELF']

    For example:

     

    <?php 
      if(isset($_POST['submit'])) {
        if(!empty($_POST['name']) {
          echo $_POST['name'];
        }
        else {
          echo 'Please enter your name!';
        }
      }
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
      <p>Name: <input type="text" name="name" /></p>
      <p><input type="submit" name="submit" value="Submit" /></p>
    </form>
    

     

  6. My favorite editors for each OS..

     

    Windows: phpDesigner 2008, in my opinion this is by far the best IDE, it also has framework support.

    Linux: gEdit, the native Gnome text editor, you can change the preferences and use plug-in's to change it into more of an IDE.

    Mac: Text-Mate, Text-Mate is my favorite IDE of all time, it supports almost all languages, has dozens of macro's, etc..

  7. You haven't really given valid comparisons. Each language can be used for a multitude of things, for example PHP is primarily a web development language, although it's also a scripting language and can be used outside of the web. Dot Net for example covers many aspects, C Sharp, ASP.NET etc..

     

    I will always stick to PHP for web development, although I still find myself inching closer and closer to Python. I'm fluent with C/C++ and those are my primary desktop development languages.

     

    I will *always* avoid Java where ever possible.

     

    I've never really took interest in Ruby, so I've never really used it, and I'm doubtful I ever will.

     

    I use Perl quite often in *nix applications as well as Python.

     

     

    It's a toughy..

  8. You're re-declaring $search, thus replacing the value of it. If somebody has used the GET method, that value will be stored and then replaced by a POST method which will contain no value at all.

     

    Try this:

    <?php
    
    //Connect to mysql server
          include 'connect.php';
    
       	//Function to sanitize values received from the form. Prevents SQL injection
       function clean($str) {
    	$str = @trim($str);
    	if(get_magic_quotes_gpc()) {
    		$str = stripslashes($str);
    	}
    	return mysql_real_escape_string($str);
    }
    
                    
            if(isset($_GET['ID'])) {
                      $search = clean($_GET['ID']); 
                    }
                    else if(isset($_POST['search'])) {
                      $search = clean($_POST['search']);
                    }
                     
           	$qry = "SELECT * FROM battle_users WHERE cname='$search'";
    $result = mysql_query($qry);
    if($result) {
    	$result_array = mysql_fetch_assoc($result);
    	if($result_array > 0) {
                     include "side.php";
       print "</td>";
       print "<td valign='top' width=70%>";
       print "<table class='maintable'><tr class='headline'><td><center>View Profile</center></td></tr>";
       print "<tr class='mainrow'><td>";
       print "<br>   Character's Profile  <br>   <br><br>";  ?>
    
    	<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
        <tr>
        <center><h2><?php print $result_array["cname"]; ?></h2>
        </center>
        <tr>
          <th>  Character's Name :-</th>
          <td><?php print $result_array["cname"]; ?></td>
        </tr>
        <tr>
          <th>  Rank :-</th>
          <td><?php if($result_array["rank"] == 0){$result_array["rank"] = "Unranked";}
    print $result_array["rank"]; ?></td>
        </tr>
    

     

    Bear in mind you also need to sanitize GET data too!

  9. Theres nothing wrong with it, it could prove useful for other people. In my personal experience, the best ever Windows IDE I've found/used is phpDesigner 2008.

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