Jump to content

Derleek

Members
  • Posts

    297
  • Joined

  • Last visited

    Never

Posts posted by Derleek

  1. sorry, let me be more clear.

     

    here is my code:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <title>Login</title>
    </head>
    <body>
    
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    screen name: <input type="text" name="login" maxlength="25"><br>
    password: <input type="password" name="pword" maxlength="25"><br>
    <input type="submit" name="submitbtn" value = "Login!">
    </form>
    or Signup <a href="SignUp.php">here</a> <br>
    <?php
    //validation code would be here...
         if(username && password are correct)
               {
                    //would be code to send user to game.php
               }
    }
    ?>
    </body>
    </html>

     

    i'd prefer to do the validation with a script on login.php, as i understand it is more efficient. So maybe i am in need of a way to do this with out generating any output...

     

    maybe the term i am looking for is not 'redirect'.  I simply need to send the user to a new page after the password and user name are varified

     

     

  2. what is the syntax to redirect  a user to a specific page?

     

    i have a script set up for user verification and i want it to redirect to a specific page when the user name and password are correct... can't seem to find the syntax for it in the php manual

     

  3. ok, so i have developed a script for validating user input?

     

    I want to make it so that if a user does not enter the data correctly he/she does not have to fill it all out again.

     

    How would i do this?

     

    I'm just not quite sure where to find a tutorial on this

     

     

  4. well, i checked out phpMyAdmin  and the it appears that the table isn't even being created... here is that code that is right before the previously posted query code.

     

    $input = "CREATE TABLE fans (
    				realName VARCHAR( 25 ) NOT NULL ,
    				uID bigint(20) NOT NULL AUTO_INCREMENT,
    				screenName VARCHAR( 25 ) NOT NULL ,
    				password VARCHAR( 25 ) NOT NULL ,
    				PRIMARY KEY (`uID`),
    				)";
    			mysql_query($input,$link);

     

    this code does not appear to be working...

  5. very true treedude... i wasn't quite sure how to format the question i wanted answered.

     

    I had a conversation with my uncle and he basically suggested the same thing as you.

     

    to have a user table, and a table with the game/info about the game as well as a table that interacts between the two.  I just couldn't wrap my brain around how awesome MySQL was hahaha.

     

    thanks,

     

    you guys rock

  6. sorry, new to this php/mySQL stuff...

     

    here is the query

     

    $uInput = sprintf("INSERT INTO fans (realName,screenName,password)
    			    VALUES( '%s', '%s','%s')",
    				mysql_real_escape_string($realName),
    			    mysql_real_escape_string($screenName),
    			    mysql_real_escape_string($password));
    			// run the query
    			if(!mysql_query($uInput))
    			    {
    			    echo 'Query failed '.mysql_error();
    			     exit();
    			    }
    			  else
    			    {
    					echo "welcome to Pro Moto Fan bench racing!!!";
    			    }
                    }

     

    i believe this is what you're looking for?

  7. i'm completely stumped... granted i'm not all that experienced with php/mySQL but i can't figure out what exactly is wrong with my code here.

     

    i'm sure there is a bunch though.

     

    the object of this program is to take user input/varify it. then if it is valid store it into a database (moto) under the table fans...  the table doesn't seem to be created correctly (obviously an issue with my code)

     

    so here it is... sorry if its sloppy...

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <title>Sign Up!</title>
    </head>
    <body>
    <p>
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <label for="name">Name:  </label>
    <input id="name" type="text" name="realName" maxlength="25" /><br />
    
    <label for="name">Screen Name:  </label>
    <input id="name" type="text" name="screenName" maxlength="25" /><br />
    
    <label for="name">Password:  </label>
    <input id="name" type="password" name="password" maxlength="25" /><br />
    
    <label for="name">Confirm Password:  </label>
    <input id="name" type="password" name="cPassword" maxlength="25" /><br />
    
    <input id="submit" type="submit" value="Sign UP!" /><br />
    </p>
    <?php
    function sanityCheck($string, $type, $length){
    
      // assign the type
      $type = 'is_'.$type;
    
      if(!$type($string))
        {
        return FALSE;
        }
      // to check if there is anything in the string
      elseif(empty($string))
        {
        return FALSE;
        }
      // to check how long the string is
      elseif(strlen($string) > $length)
        {
        return FALSE;
        }
      else
        {
        // if all is well, we return TRUE
        return TRUE;
        }
    }
    
    function checkSet(){
      return isset($_POST['realName'], $_POST['screenName'], $_POST['password'], $_POST['cPassword']);
    }
    if(checkSet() != FALSE)
    {
    if(empty($_POST['realName'])==FALSE && sanityCheck($_POST['realName'], 'string', 25)!=FALSE && empty($_POST['screenName'])==FALSE && sanityCheck($_POST['screenName'], 'string', 25)!=FALSE && empty($_POST['password'])==FALSE && sanityCheck($_POST['password'], 'string', 25)!=FALSE)
                    {
            //If all is well  the value of the POST is assigned to a variable...
                    $realName = $_POST['realName'];
    			$screenName = $_POST['screenName'];
    			$password = $_POST['password'];
    			$cPassword = $_POST['cPassword'];
    			if($password !=$cPassword)
    				{
    				echo 'your passwords don not match';
    				exit();
    				}
    			$link = @mysql_connect('localhost', 'root', 'zOinks12');
    			if (!$link) 
    			    {
    			    die('Not connected : ' . mysql_error());
    			    }
    
    			$db_selected = mysql_select_db('moto', $link);
    			if (!$db_selected)
    			    {
    			    die ("Database not selected : " . mysql_error());
    			    }
    
    				$input = "CREATE TABLE fans (
    				realName VARCHAR( 25 ) NOT NULL ,
    				screenName VARCHAR( 100 ) NOT NULL ,
    				password VARCHAR( 25 ) NOT NULL ,
    				)";
    			mysql_query($input,$link);
    			// Query
    			$uInput = sprintf("INSERT INTO fans (realName,screenName,password)
    			    VALUES( '%s', '%s','%s')",
    				mysql_real_escape_string($realName),
    			    mysql_real_escape_string($screenName),
    			    mysql_real_escape_string($password));
    			// run the query
    			if(!mysql_query($uInput))
    			    {
    			    echo 'Query failed '.mysql_error();
    			     exit();
    			    }
    			  else
    			    {
    					echo "welcome to Pro Moto Fan bench racing!!!";
    			    }
                    }
    		else
                    {
                    echo 'You did not fill out all of the fields!!';
                    exit();
                    }
    }
    else
    {
    	echo "Please fill out all of the above!";
    }
    ?>
    </body>
    
    </html>

  8. I'm a bit new to MySQL and PHP... so i think this should be a simple question/answer.

     

    I'm creating a MySQL database that needs to support MANY different users and save all of their information (for a game).

     

    I have a decent amount of experience using C++, i'm just now venturing into the php realm.  I can conceptualize an array to fit the data i need quite easily, i'm just not sure how MySQL handles what would be a 'multi-dimmensional array' in C++

     

    I'm wondering if i should create an individual table for every user or just use one table to store all users and all of their information.

     

    i picture the data base i need as follows

     

    *Username*(main table)

     

    Sub sections:

    Password

    realName

    game choices [needs to store 10 different choices]

    raceNumber

     

    Does MySQL support multi-dimmensional arrays (which i think i would need for game choices) or is there a good to tie information together.

     

    -thanks for reading my programming dilemma's  ;)

  9. Hi, i'm new to the world of coding for the web.  I have a good amount of C++ experience... but i'm having trouble conceptualizing how the best way to handle variables from one page to another.

     

    For example, if i am creating a game and i want to validate the input.

     

    Is there a way to handle the html form on that same page that they input it?

     

    ok so basically can i take this basic form handling script....

     

    Form:

     <form action="welcome.php" method="post">
    Name: <input type="text" name="name" />
    Age: <input type="text" name="age" />
    <input type="submit" />
    </form>

     

    welcome.php:

    <html>
    <body>
    
    Welcome <?php echo $_POST["name"]; ?>.<br />
    You are <?php echo $_POST["age"]; ?> years old.
    
    </body>
    </html>
    

     

    and make it do something like this...

     

    welcome.php:

    <html>
    
    <body>
    <form action="randomFunction()" method="post">
    Name: <input type="text" name="name" />
    Age: <input type="text" name="age" />
    <input type="submit" />
    </form>
    <?php
    function randomFunction() {
    //validate input 
    }
    ?>
    </body>
    </html>
    

     

    I'm really asking this for efficiency sake... I'm wondering if the best approach is to create a temporary MySQL table then validate using a separate php script, proceed to store the data permanently...

     

    so if that doesn't make any sense, what is the best method to receive user input/validate and store using MySQL...

  10. [pre]Hi,

    i'm new to php, needless to say i'm having trouble with the admin function of MySQL for Apache friend's XAMP it gives me an odd error whenever i have the admin window open through the control pannel.

     

    "access violation at adress 10002593 in module "LIBMYSQL.DLL" read of address 00000000"

     

    I have no clue what could be going on so any insight would be great[/pre]

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