Jump to content

PHP Form Validatign


uramagget

Recommended Posts

<?
include "top.txt";
// get posted data into local variables
$username = Trim(stripslashes($_POST['username'])); 
$email = Trim(stripslashes($_POST['email'])); 
$password = Trim(stripslashes($_POST['password'])); 
$subdomain = Trim(stripslashes($_POST['subdomain']));
$currenturl = Trim(stripslashes($_POST['currenturl']));

//Send to, and subject.
$emailto = "[email protected]";
$subject = "PokeRindin Hosting";


// Check if filled in/empty
if (Trim($email)==""){
echo "You forgot to fill in your E-Mail";
}

elseif (Trim($username)==""){
echo "You forgot to fill in your Username";
}
elseif (Trim($password)==""){
echo "You forgot to fill in your Password";
}
elseif (Trim($subdomain)==""){
echo "You forgot to fill in your Subdomain";
}


// prepare email body text
$Body = "";
$Body .= "Username: ";
$Body .= $username;
$Body .= "\n";
$Body .= "Password: ";
$Body .= $password;
$Body .= "\n";
$Body .= "Sub-domain: ";
$Body .= $subdomain;
$Body .= "\n";
$Body .= "Current URL: ";
$Body .= $currenturl;
$Body .= "\n";

// send email 
$success = mail($emailto, $subject, $Body, "From: <$email>");

// redirect to success page 
if ($success){
  echo "Your application was sent to Rindiny, and is awaiting approval. Can you join our forum while you wait, please?";
}
else{
  echo "Eeek! the form couldn't go through right. Only one thing to do. Contact Rindiny([email protected]), or try the form again. D: ";
}
include "bottom.txt";
?>

 

 

I'm trying to write a form where it makes users require them to fill it in, though even with the if code, the form is submitted, so I can't find out why this doesn't work.

Link to comment
https://forums.phpfreaks.com/topic/59951-php-form-validatign/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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