Please help with my code [Form submission]
Posted: Thu Jul 09, 2009 8:06 pm
Hello,
I am trying to retrieve form submission in PHP class. I am unable to retrieve any thing. Please tell me where I am going wrong.
HTML form:
Thank you,
I am trying to retrieve form submission in PHP class. I am unable to retrieve any thing. Please tell me where I am going wrong.
HTML form:
Code: Select all
<form action="inc/Index.php" method="POST">
firstname:<input type="text" name="firstname" value="" />
<br>
lastname:<input type="text" name="lastname" value="" />
<br>
Email:<input type="text" name="email1" value="" />
<br>
Email:<input type="text" name="email2" value="" />
<br>
Password:<input type="text" name="password1" value="" />
<br>
Password:<input type="text" name="password2" value="" />
<br>
<input type="submit" value="" />
</form>Code: Select all
<?php
include "DBConnection.php";
class Index {
// Main() method
function Index(){
if(ISSET($_POST['SUBMIT'])){
$firstname = stripslashes($_POST['firstname']);
$lastname = stripslashes($_POST['lastname']);
$email1 = striplashes($_POST['email1']);
$email2 = stripslashes($_POST['email2']);
$password1 = stripslashes($_POST['password1']);
$password2 = stripslashes($_POST['password2']);
// Check for empty values
if(empty($_POST['firstname'])){ header("Location: ../index.php?error=firstname"); exit(); }
if(empty($_POST['lastname'])){ header("Location: ../index.php?error=lastname");exit(); }
if(empty($_POST['email1'])){ header("Location: ../index.php?error=email");exit(); }
if(empty($_POST['email2'])){ header("Location: ../index.php?error=email");exit(); }
if(empty($_POST['password1'])){ header("Location: ../index.php?error=password");exit(); }
if(empty($_POST['password2'])){ header("Location: ../index.php?error=password");exit(); }
// Check for similarity
if($email1 != $email2){ header("Location: ../index.php?error=emailMissMatch"); exit(); }
if($password1 != $password2){ header("Location: ../index.php?error=passwordMissMatch"); exit(); }
/*
// Database connection operation
$dbConnection = new DBConnection;
$dbConnection -> DBConnection();
// MySQL Operation
$sql_answer = mysql_query("select * from userdata where email = '".$email1."'");
$sql_row = mysql_num_rows($sql_answer);
// Check user exist/dont exist
if($sql_row > 0){
header("Location: http://www.x.com/login/index.php?value=userExist");
exit();
}
*/
// Generate random number
$random_number = rand(000000000, 999999999);
print $random_number;
/*
// Send email
$email = new Email;
$email ->Email($email1, $random_number);
*/
}else{
header("Location: ../index.php");
}
//
} // end of fuction index()
}
?>