News:

Server address: server.convoytrucking.net
Get SA-MP 0.3.7 here: Click Here to download SA-MP 0.3.7

Main Menu

PHP help pl0x?

Started by CarlJohnson, January 04, 2018, 05:05

CarlJohnson

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:
<!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

Tyler

/<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

Loup

The line of *filter_validate_email* at the end there is a bracket opened and not closed anywhere.

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

ADMIN SINCE
19 Dec 2022
MODERATOR SINCE
16 Dec 2019
COUNTRY
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

Emily

Quote from: Loup on January 04, 2018, 09:22
The line of *filter_validate_email* at the end there is a bracket opened and not closed anywhere.

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

                        else
{
$email = test_input($_POST["email"]);
    // check if e-mail address is well-formed
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
[dobby]

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

CarlJohnson

Quote from: Emily on January 04, 2018, 09:30
Quote from: Loup on January 04, 2018, 09:22
The line of *filter_validate_email* at the end there is a bracket opened and not closed anywhere.

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

                        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