Results 1 to 4 of 4

Thread: [RESOLVED] Diffrent php Files

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Resolved [RESOLVED] Diffrent php Files

    Hello,

    Is it possible to put my php code in one file called process.php and the html code in a file called form.php if so can someone help me please.?

    PHP Code:
    <?php
    $button 
    null;
    if (isset(
    $_POST['button']))
    {
        
    $button $_POST["button"];
    }
    if (
    $button)
    {
        
    //Get Data
        
    $username $_POST['username'];
        
    $password $_POST['password'];
        
    $retypepassword $_POST['retypepassword'];
        
    $email $_POST['email'];
        
        if (
    $username && $password && $retypepassword && $email)
        {
            if (
    $password == $retypepassword)
            {
                if (
    strstr($email".") && strstr($email"@"))
                {
                    include (
    "connect.php");
                    
    $query mysql_query ("SELECT * FROM users WHERE username='$username'");
                    
    $numrows mysql_num_rows($query);
                    if (
    $numrows == 0)
                    {
                        
    $password md5($password);
                        
    $insert "INSERT INTO users VALUES('', '$username', '$password' , '$email')";
                        
    $register mysql_query($insert) or die (mysql_error());
                        echo 
    "You have been registered";
                    }
            else
                    echo 
    "That username is taken.";
                }
                else
                    echo 
    "Not a vailid email address.";
            }
            else
                echo 
    "Passwords did not match";
        }
        else
            echo 
    "You did not fill in the entire form";
        
    }
    else
    {
        
    ?>
        <FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table width='300'>

    <tr>
        <td align='right'>Username:</td>
        <td align='left'><input type='text' name='username'></td>
    </tr>

    <tr>
        <td align='right'>Password:</td>
        <td align='left'><input type='password' name='password'></td>
    </tr>

    <tr>
        <td align='right'>Retype Password:</td>
        <td align='left'><input type='password' name='retypepassword'></td>
    </tr>

    <tr>
        <td align='right'>Email</td>
        <td align='left'><input type='text' name='email'></td>
    </tr>

    <tr>
        <td align='right'></td>
        <td align='left'><input type='submit' name='button' value='Register'></td>
    </tr>

    </table>
    </form>

    <?php
    }

    ?>
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  2. #2
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: Diffrent php Files

    well if you want the form to send to form.php and not process.php then you could put the code you want it process.php and the include("process.php"); into form.php?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Diffrent php Files

    this is the new code but i keep geting errors now

    Parse error: syntax error, unexpected '}' in /home/markhost/public_html/process_login.php on line 37

    Code:
    <?php
    $button = null;
    if (isset($_POST['button']))
    {
    	$button = $_POST["button"];
    }
    if ($button)
    {
    	//Get Data
    	$username = $_POST['username'];
    	$password = $_POST['password'];
    	$retypepassword = $_POST['retypepassword'];
    	$email = $_POST['email'];
    	
    	if ($username && $password && $retypepassword && $email)
    	{
    		if ($password == $retypepassword)
    		{
    			if (strstr($email, ".") && strstr($email, "@"))
    			{
    				include ("connect.php");
    				$query = mysql_query ("SELECT * FROM users WHERE username='$username'");
    				$numrows = mysql_num_rows($query);
    				if ($numrows == 0)
    				{
    					$password = md5($password);
    					$insert = "INSERT INTO users VALUES('', '$username', '$password' , '$email')";
    					$register = mysql_query($insert) or die (mysql_error());
    					//echo "You have been registered";
    
    
    					//IF LOGIN IS GOOD REDIRECT
    					$location = "login.php"
    					//or
    					//Just login.php like below
    					//header("location:login.php");
    			}
    		else
    				echo "That username is taken.";
    			}
    			else
    				echo "Not a vailid email address.";
    		}
    		else
    			echo "Passwords did not match";
    	}
    	else
    		echo "You did not fill in the entire form";
    	
    }
    ?>
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: [RESOLVED] Diffrent php Files

    you have an extra ending brace ("}") somewhere around line 37, or possibly an unterminated statement.
    Like Archer? Check out some Sterling Archer quotes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width