Author Topic: PHP help pl0x?  (Read 870 times)

Offline CarlJohnson

  • Administrator
  • Hero Member
  • ******
  • Posts: 3,193
  • cookies: 85
  • Server Scripter
  • IG name: CarlJohnson
PHP help pl0x?
« on: January 04, 2018, 05:05 »
Hi, I recently decided to learn PHP and went ahead with working on a project which includes registering details and storing / extracting them from MySQL. I'm creating a registration page right now but I'm facing a problem / error.

Error: Parse error: syntax error, unexpected end of file in /storage/ssd4/874/3563874/public_html/bloodreg.php on line 117

Code:
Code: [Select]
<!DOCTYPE HTML>
<html>
<head>
<stlye>
.error {color: #FF0000;}
</stlye>
<title>Blood Bank Registration</title>
</head>

<body>
<?php
$name $age $contactno $email $bloodtype "";
$nameErr $ageErr $contactnoErr $emailErr $bloodtypeErr "";

if ($_SERVER["REQUEST METHOD"] == "POST"
{
if (empty($POST["name"]))
{
$nameErr "Name is required!";
}
else 
{
$name test_input($POST["name"]);
// check if name only contains alphabets and whitespaces
if (!preg_match("/^[a-zA-Z ]*$/"$name))
{
$nameErr "Only letters and white spaces are allowed!";
}
}

if (empty($POST["age"]))
{
$ageErr "Age is required!";
}
else 
{
if (!preg_match("/^[0-9][9-0]*$/"$age))
{
$ageErr "Only numbers are allowed!";
}
}

if (empty($POST["contactno"]))
{
$contactnoErr "Contact Number is required!";
}
else 
{
if (!preg_match("/^[0-9][9-0]*$/"$age))
{
$contactnoErr "Only numbers are allowed!";
}
}

if (empty($POST["email"]))
{
$email "";
}
else
{
$email test_input($_POST["email"]);
   
// check if e-mail address is well-formed
    
if (!filter_var($emailFILTER_VALIDATE_EMAIL)) {
     
$emailErr "Invalid email format"
}
if (empty($POST["bloodtype"]))
{
$bloodtypeErr "Blood Type is required!";
}
}


function test_input($data
{
  
$data trim($data);
  
$data stripslashes($data);
  
$data htmlspecialchars($data);
  
return $data;
  
}
?>

<h2>Blood Donation Registration</h2>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 
  Name: <input type="text" name="name" value="<?php echo $name;?>">
  <span class="error">* <?php echo $nameErr;?></span>
  <br><br>
  E-mail: <input type="text" name="email" value="<?php echo $email;?>">
  <span class="error">* <?php echo $emailErr;?></span>
  <br><br>
  Age: <input type="text" name="age" value="<?php echo $age;?>">
  <span class="error"><?php echo $ageErr;?></span>
  <br><br>
  Contact Number: <input type = "text" name="contactno" value="<?php echo $contactno;?>">
  <span class = "error"><?php echo $contactnoErr;?></span>
  <br><br>
  Blood Type / Group: <input type = "text" name="bloodtype" value="<?php echo $bloodtype;?>">
  <span class = "error"><?php echo $bloodtypeErr;?></span>
  <br><br>
  <input type="submit" name="submit" value="Submit"> 
</form>


<?php
echo "<h2>Your Input:</h2>";
echo 
$name;
echo 
"<br>";
echo 
$email;
echo 
"<br>";
echo 
$age;
echo 
"<br>";
echo 
$contactno;
echo 
"<br>";
echo 
$bloodtype
?>


</body>
</html>

What am I doing wrong here?

If anyone wanna visit, website is at: https://prateekrawat.000webhostapp.com

LAST SEEN
TOTAL TIME ON SERVER
SCORE
TRUCK LOADS
CONVOY SCORE
ACHIEVEMENTS
ARTIC
DUMPER
VAN
FUEL
CEMENT
ARRESTS
CARS STOLEN
COACH
PLANE
HELICOPTER
TOW TRUCK
LIMO
TRASH
ARMORED VAN

Offline Tyler

  • Administrator
  • Hero Member
  • ******
  • Posts: 2,094
  • cookies: 41
  • ¡Tengo los pantalones!
  • IG name: Tyler
Re: PHP help pl0x?
« Reply #1 on: January 04, 2018, 06:00 »
Code: [Select]
/<stlye>
.error {color: #FF0000;}
</stlye>

style is spelt incorrectly

and you are missing a } somewhere. You have 16 opening brackets and only 15 closing brackets.

[23:19:46] (CB:16) Fish: thats going in my sig

Offline Loup

  • Respected Trucker
  • ***
  • Posts: 124
  • cookies: 3
  • Ware Wolf - Hacker
  • IG name: Loup
Re: PHP help pl0x?
« Reply #2 on: January 04, 2018, 09:22 »
The line of *filter_validate_email* at the end there is a bracket opened and not closed anywhere.

Code: [Select]
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

Offline Emily

  • VIP
  • Hero Member
  • *****
  • Posts: 877
  • cookies: 42
  • IG name: Emily
Re: PHP help pl0x?
« Reply #3 on: January 04, 2018, 09:30 »
The line of *filter_validate_email* at the end there is a bracket opened and not closed anywhere.

Code: [Select]
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

well this general vicinity looks incorrect according to brackets, I'm thinking it's this else statement here
Code: [Select]
                        else
{
$email = test_input($_POST["email"]);
    // check if e-mail address is well-formed
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
Hover your mouse here and reveal the mystery

LAST SEEN
TOTAL TIME ON SERVER
SCORE
TRUCK LOADS
CONVOY SCORE
ACHIEVEMENTS
ARTIC
DUMPER
VAN
FUEL
CEMENT
ARRESTS
CARS STOLEN
COACH
PLANE
HELICOPTER
TOW TRUCK
LIMO
TRASH
ARMORED VAN
BURGLARIES
ARMORED VANS STOLEN
MISSIONS FAILED
OVERLOADED
FINES PAID
TOTAL SPENT ON FUEL
INTEREST EARNED
DISTANCE TRAVELLED
TIME IN JAIL
LAST MISSION

Offline CarlJohnson

  • Administrator
  • Hero Member
  • ******
  • Posts: 3,193
  • cookies: 85
  • Server Scripter
  • IG name: CarlJohnson
Re: PHP help pl0x?
« Reply #4 on: January 04, 2018, 11:00 »
The line of *filter_validate_email* at the end there is a bracket opened and not closed anywhere.

Code: [Select]
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

well this general vicinity looks incorrect according to brackets, I'm thinking it's this else statement here
Code: [Select]
                        else
{
$email = test_input($_POST["email"]);
    // check if e-mail address is well-formed
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
Yes it was. Thanks for the help guys.
LAST SEEN
TOTAL TIME ON SERVER
SCORE
TRUCK LOADS
CONVOY SCORE
ACHIEVEMENTS
ARTIC
DUMPER
VAN
FUEL
CEMENT
ARRESTS
CARS STOLEN
COACH
PLANE
HELICOPTER
TOW TRUCK
LIMO
TRASH
ARMORED VAN

 

anything