|
-
Jan 7th, 2011, 04:13 PM
#1
Thread Starter
Frenzied Member
[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
-
Jan 7th, 2011, 04:27 PM
#2
Fanatic Member
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?
-
Jan 7th, 2011, 05:08 PM
#3
Thread Starter
Frenzied Member
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
-
Jan 7th, 2011, 08:41 PM
#4
Re: [RESOLVED] Diffrent php Files
you have an extra ending brace ("}") somewhere around line 37, or possibly an unterminated statement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|