Jump to content

Dathremar

Members
  • Posts

    169
  • Joined

  • Last visited

Posts posted by Dathremar

  1. I would suggest setting the name of the input to :

     

    <input type='checkbox' name='song[]' value='".$narray[$i]."'>".$narray[$i]."</input>
    

     

    So it would be an array when You submit it.

     

    Also when You get the variable on the other side

     

    $song_array = $_POST['song'];
    
    for ($i=0; $i < count($song_array); $i++)
    {
    // print out the xml
    }
    

  2. <?php session_start();
    
    include 'Utilitys/Connection.php';
    include 'Utilitys/Functions.php';
    
    if (isset($_POST['submit'])) {
    
    $role = "1";
    $id = mt_rand(0, 9999999999);
    $time = date("F j, Y, g:i a");
    $signup = date("F j, Y, g:i a");
    $username = protect($_POST['Username']);
    $password = protect(md5($_POST['Password']));
    $firstname = protect($_POST['FirstName']);
    $lastname = protect($_POST['LastName']);
    $email = protect($_POST['Email']);
    
    if (isset($role) && isset($id) && isset($time) && isset($signup) && isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email)) {
    
    	$save = "SELECT * FROM `users` WHERE username LIKE '$username'" or die (mysql_error());
    	$result = mysql_query($save);
    
    	if (mysql_num_row($result) > 0) {
    
    		$flag = "INSERT INTO `users` ('id', 'username', 'password', 'firstname', 'lastname', 'email', 'role', 'time', 'signup', 'gender')                  
    		 VALUES('$id', '$username', '$password', '$firstname', '$lastname', '$email', '$role', '$time', '$signup')" or die (mysql_error());
    
    		$run = mysql_query($flag);
    
    		print "<p align='center'>Welcome $username,<br>You Have Now Been Register, Please <a href='Login.php'>Login</a><br>Many Thanks,<br>Admin.</p>";
    	} 
    	else {
    
    		print "<p align='center'>Please Fill All Required Fields.</p>";
    
    	} 
    }
    else {
    
    print "<p align='center'>Sorry But That Username ($username) Already Exist's, <br> Please Try Again.</p>";
    
    } // another bracket missing
    }
    ?>
    

    Edited to put the code in php tags :/

    There was 1 more missing bracket at the end

  3. There are issues with your code Dathremar.

    1. The trim function is being used on a variable that has already been trimmed

    2. There is no need to use an else statement after an exit function. The script will terminate if the condition is not met.

     

    Thirdly you code should check for a valid email address not just if the field is empty.

    <?php
    // get posted data into local variables
    $mail = trim($_POST['mail']);
    if(!eregi("^[^@]{1,64}@[^@]{1,255}$", $mail)) {
    exit("Please enter a valid E-Mail address.");
    }
    echo "The E-Mail You Entered Is ".$mail;
    ?>
    

     

    You are right, sorry. Didn't pay attention to that, I just copied his coded and change the part for echo of the variable.

    Was in a hurry and i neglected the code itself :S

  4. I would suggest for you to use javascript to check this.

     

    Here is a javascript function

     

    function Check_chars( data )
    {
       var iChars = "!@#$%^&*()+=-[]\\\';,{}|\"<>?~_"; // Just put here what You want to be considered as invalid char
       for (var i = 0; i < data.length; i++) {
      	if (iChars.indexOf(data.charAt(i)) != -1) {
      	  //alert ("Your string has special characters. \nThese are not allowed.");
      	return false;
      	}
      }
      return true;
    }
    

  5. <?php
    if (isset($select_var))
    {
      switch($select_var)
        case 1:
          $var_array = array("blah1","blah2","blah3","blah4");
          break;
        case 2:
          $var_array = array("foo1","foo2","foo3","foo4");
          break;
        case 3:
          $var_array = array("nothing1","nothing2","nothing3","nothing4");
          break;
    }
    
    // do what ever you want with $var_array
    ?>
    <select name='select_var'>
    <option value="var1">1</option>
    <option value="var2">2</option>
    <option value="var3">3</option>
    </select>
    

     

    Think this will help

  6. I wanted to do this, after a lot of googling I found some examples how it is made.

     

    The thing is like OP said this is not doable in a normal drop down. You will have to use CSS and javascript.  So You will put all the options and the images into divs and then make them look like drop down list with css. Then add javascript functions for the onClick method, mouseover etc.

     

    GL making that :)

     

    P.S. I did't make it :( My contractor gave me too little time to play around ;)

  7. For paging u need couple of things to keep in mind. Like number of all rows, rows presented on page. So when you execute the query set up a limit in the SQL. And transfer from 1 page to another the number of rows that needs to be displayed (if it is changable) and the last number of the last displayed row.

     

    Also You can find some really nice paging script on the web. Just use google a bit ;)

     

    have fun

  8. Well the tables were for work in progress and not valid data in it. So renaming all indexes was kinda too much trouble and I thought that dropping the tables and recreating them (have sql queries  from the program that i am creating the design) would be easier.

     

    I already dropped the whole db and recreated it from scratch :( Something that I thought was easier and faster ended up in loosing whole day in troubleshooting :S Ahh well I guess it happens.

     

    P.S. I think that the Fk on the other end matched the one i was creating. Think i checked that. But thanks anyway. Will keep that in mind for next time ;)

  9. Do what the OP said but plz dont put the $_GET variable directly into the sql :)

     

    Take the content of the $_GET variable and then check if contains the information that You want and then put it in the sql.

     

    Or even better just put some URL variable to determine what where statement to use for ex:

     

    1 means "where bla = bla1"

    2 means "where bla = bla2"

    etc

     

    So make a switch statement to determine which of the predefined sql to use.

     

    This is only for your own safty. Putting URl variables or anykind of variables directly into the sql can result sql injections.

    Hope I helped You ;)

     

    P.S. I wrote this in a hurry so if u need more information please say so :)

     

     

  10. i will try to describe this as much as I can.

     

    So i have db with some tables which index names were not named as I wanted, so I decided to drop all the current tables and make them again with the new names for the indexes.

     

    Now after dropping the tables I try to create it again and I get error ERROR 1005: Can't create table './db/table.frm' (errno: 150), which is a foreign key constraint error. But how can this be ?!? I dropped the table and now i am creating it without any foreign key / index (gonna add them when i will finish adding the tables) and it still says that foreign key constraint fails. Which is more odd is that it is referring to an old table which also does not exist.  ???

     

    I am really confused. Have this happened to some1 else ? Have you solved the problem? Or this is some kind of db corruption that happened when i was droping and creating new tables?

     

    Thanks in advance

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