PDA

View Full Version : Whats wrong with this code?



Pazza
19-08-2008, 01:28 PM
Hey,

Excellent drew me up a code for job applications, and I've tried to edit it but I get this error when I visit the page:
Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/bobbafmc/public_html/app/radiomanager.php on line 18

This is my code:


<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.

else //Maybe..

{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['Radio Manager']));
$job = addslashes(htmlspecialchars($_POST['job']));
$exp = addslashes(htmlspecialchars($_POST['Any Experience?']));
$now = addslashes(htmlspecialchars($_POST['Are they working now?']));
$unique = addslashes(htmlspecialchars($_POST[How are they unique']));
$them = addslashes(htmlspecialchars($_POST['About them']));
$why = addslashes(htmlspecialchars($_POST['Why BobbaFM, What will they bring?']));

$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$subject = "$name with the e-mail: $email has applied for the job: $job !"; //Displays the name and the job in the email subject.
$mess = "Heres their details:
Name: $name
Email: $email
Job: $job $sub
Their Experience:
$exp
Are they working now:
$now
How are they unique:
$unique
About them:
$them
Why and what will they bring to bobbafm:
$why";

mail("$mail","$subject","$mess"); //We use the mail(); function to send the email.

echo "Your application has been sent, we will reply within 48 hours!"; //Hooharr! Success!
$email = "$email";
$message = "Your application has been recieved for the job $job !.You will recieve another e-mail within the next 48 hours regarding whether or not you have been successful. Good Luck!";
$headers = "From: [email protected]";
mail("$email","$message","$headers");
} //End the else.
} // End the post.

else //Form time!

{

echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio Manager (x3)</option>
</select><br>
Do you have any experience at Being a Radio manager, if yes then where?<br>
<textarea name='Any experience?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
Do you currently have a job anywhere, if so where? <br>
<textarea name='Are they working now?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
What sets you aside from all other Applicants?<br>
<textarea name='How are they unique' cols='45' rows='4'>Try and put in as much detail as you can!</textarea><br>
Give me some info about yourself :)<br>
<textarea name='About them' cols='45' rows='5'>Hi my name is bob I am 98 and I am hip hop cooooool</textarea><br>
Why BobbaFM, and what will you bring to BobbaFM?<br>
<textarea name='Why BobbaFM, What will they bring?' cols='45' rows='5'>I would like to work at bobbafm because its new, and I want to contribute to it becoming successful. To do this, I will bring ... (try and do something like that)</textarea><br>
<input type='submit' name='send' value='Submit'></form>";
//You can change these values or whatever, have fun.

} //End the last else.
?>

If you could tell me whats wrong, or edit (i'm new to php) i'd be grateful.

Trinity
19-08-2008, 01:41 PM
<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.

else //Maybe..

{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['Radio Manager']));
$job = addslashes(htmlspecialchars($_POST['job']));
$exp = addslashes(htmlspecialchars($_POST['Any Experience?']));
$now = addslashes(htmlspecialchars($_POST['Are they working now?']));
$unique = addslashes(htmlspecialchars($_POST['How are they unique']));
$them = addslashes(htmlspecialchars($_POST['About them']));
$why = addslashes(htmlspecialchars($_POST['Why BobbaFM, What will they bring?']));

$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$subject = "$name with the e-mail: $email has applied for the job: $job !"; //Displays the name and the job in the email subject.
$mess = "Heres their details:
Name: $name
Email: $email
Job: $job $sub
Their Experience:
$exp
Are they working now:
$now
How are they unique:
$unique
About them:
$them
Why and what will they bring to bobbafm:
$why";

mail("$mail","$subject","$mess"); //We use the mail(); function to send the email.

echo "Your application has been sent, we will reply within 48 hours!"; //Hooharr! Success!
$email = "$email";
$message = "Your application has been recieved for the job $job !.You will recieve another e-mail within the next 48 hours regarding whether or not you have been successful. Good Luck!";
$headers = "From: [email protected]";
mail("$email","$message","$headers");
} //End the else.
} // End the post.

else //Form time!

{

echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio Manager (x3)</option>
</select><br>
Do you have any experience at Being a Radio manager, if yes then where?<br>
<textarea name='Any experience?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
Do you currently have a job anywhere, if so where? <br>
<textarea name='Are they working now?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
What sets you aside from all other Applicants?<br>
<textarea name='How are they unique' cols='45' rows='4'>Try and put in as much detail as you can!</textarea><br>
Give me some info about yourself :)<br>
<textarea name='About them' cols='45' rows='5'>Hi my name is bob I am 98 and I am hip hop cooooool</textarea><br>
Why BobbaFM, and what will you bring to BobbaFM?<br>
<textarea name='Why BobbaFM, What will they bring?' cols='45' rows='5'>I would like to work at bobbafm because its new, and I want to contribute to it becoming successful. To do this, I will bring ... (try and do something like that)</textarea><br>
<input type='submit' name='send' value='Submit></form>";
//You can change these values or whatever, have fun.

} //End the last else.
?>

Excellent1
19-08-2008, 01:56 PM
Yeah you left out a ' so it wasn't expecting the ]

Pazza
19-08-2008, 02:42 PM
<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.

else //Maybe..

{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['Radio Manager']));
$job = addslashes(htmlspecialchars($_POST['job']));
$exp = addslashes(htmlspecialchars($_POST['Any Experience?']));
$now = addslashes(htmlspecialchars($_POST['Are they working now?']));
$unique = addslashes(htmlspecialchars($_POST['How are they unique']));
$them = addslashes(htmlspecialchars($_POST['About them']));
$why = addslashes(htmlspecialchars($_POST['Why BobbaFM, What will they bring?']));

$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$subject = "$name with the e-mail: $email has applied for the job: $job !"; //Displays the name and the job in the email subject.
$mess = "Heres their details:
Name: $name
Email: $email
Job: $job $sub
Their Experience:
$exp
Are they working now:
$now
How are they unique:
$unique
About them:
$them
Why and what will they bring to bobbafm:
$why";

mail("$mail","$subject","$mess"); //We use the mail(); function to send the email.

echo "Your application has been sent, we will reply within 48 hours!"; //Hooharr! Success!
$email = "$email";
$message = "Your application has been recieved for the job $job !.You will recieve another e-mail within the next 48 hours regarding whether or not you have been successful. Good Luck!";
$headers = "From: [email protected]";
mail("$email","$message","$headers");
} //End the else.
} // End the post.

else //Form time!

{

echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio Manager (x3)</option>
</select><br>
Do you have any experience at Being a Radio manager, if yes then where?<br>
<textarea name='Any experience?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
Do you currently have a job anywhere, if so where? <br>
<textarea name='Are they working now?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
What sets you aside from all other Applicants?<br>
<textarea name='How are they unique' cols='45' rows='4'>Try and put in as much detail as you can!</textarea><br>
Give me some info about yourself :)<br>
<textarea name='About them' cols='45' rows='5'>Hi my name is bob I am 98 and I am hip hop cooooool</textarea><br>
Why BobbaFM, and what will you bring to BobbaFM?<br>
<textarea name='Why BobbaFM, What will they bring?' cols='45' rows='5'>I would like to work at bobbafm because its new, and I want to contribute to it becoming successful. To do this, I will bring ... (try and do something like that)</textarea><br>
<input type='submit' name='send' value='Submit></form>";
//You can change these values or whatever, have fun.

} //End the last else.
?>

Tysvm :)


Yeah you left out a ' so it wasn't expecting the ]

Bloodyhell its more picky than a vegetarian shark (crap metaphor)

I owe you Trinity :)

AAAAAAH FGS - It isn't working, it just refreshes page and the application doesn't get sent :(

Any ideas?

Trinity
19-08-2008, 03:04 PM
At the top of the script, you have:

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
}
Why are you checking for $_POST['sub'], I can't find anything with that name, which would cause the script to always give the message "Some fields have been left blank, please go back and refill them!"

Or I've just not read through it properly :)

Excellent1
19-08-2008, 03:13 PM
Yeah, remove the (!$_POST['sub']) from the top as you haven't defined that variable in your form, you will get "Some fields have been left blank".

Pazza
19-08-2008, 03:25 PM
At the top of the script, you have:

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['sub']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
}Why are you checking for $_POST['sub'], I can't find anything with that name, which would cause the script to always give the message "Some fields have been left blank, please go back and refill them!"

Or I've just not read through it properly :)

Ahhh,

It's excellents code, and I've evited it and renamed some things, and i've just forgot to add it up there.

Just changed it and its still not working ;(

Trinity
19-08-2008, 03:26 PM
Ahhh,

It's excellents code, and I've evited it and renamed some things, and i've just forgot to add it up there.

Just changed it and its still not working ;(

Post your updated code and I'll take a look.

Excellent1
19-08-2008, 03:28 PM
Try this:
On your drop downs you have defined value twice, it should be:

<option label="blah" value="blah">Blah</option>

Pazza
19-08-2008, 03:32 PM
Nope, the page just refreshes and application doesn't get sent :(

Excellent1
19-08-2008, 03:38 PM
Delete your code and use this:

<?php
if(isset($_POST['send'])) { //Checks if the applicant has submitted the form.

if((!$_POST['email']) || (!$_POST['name']) || (!$_POST['job'])) { //Make sure they have filled in all fields.

echo "Some fields have been left blank, please go back and refill them!"; //Display the error.
} //End the check on the fields.

else //Maybe..

{
$email = addslashes(htmlspecialchars($_POST['email'])); //Removes the slashes.
$name = addslashes(htmlspecialchars($_POST['name']));
$sub = addslashes(htmlspecialchars($_POST['Radio Manager']));
$job = addslashes(htmlspecialchars($_POST['job']));
$exp = addslashes(htmlspecialchars($_POST['Any Experience?']));
$now = addslashes(htmlspecialchars($_POST['Are they working now?']));
$unique = addslashes(htmlspecialchars($_POST['How are they unique']));
$them = addslashes(htmlspecialchars($_POST['About them']));
$why = addslashes(htmlspecialchars($_POST['Why BobbaFM, What will they bring?']));

$mail = "[email protected]"; //Change this to the the email you want the message to go to.
$subject = "$name with the e-mail: $email has applied for the job: $job !"; //Displays the name and the job in the email subject.
$mess = "Heres their details:
Name: $name
Email: $email
Job: $job $sub
Their Experience:
$exp
Are they working now:
$now
How are they unique:
$unique
About them:
$them
Why and what will they bring to bobbafm:
$why";

mail("$mail","$subject","$mess"); //We use the mail(); function to send the email.

echo "Your application has been sent, we will reply within 48 hours!"; //Hooharr! Success!
$email = "$email";
$message = "Your application has been recieved for the job $job !.You will recieve another e-mail within the next 48 hours regarding whether or not you have been successful. Good Luck!";
$headers = "From: [email protected]";
mail("$email","$message","$headers");
} //End the else.
} // End the post.

else //Form time!

{

echo "<form method='post' action='$_SERVER[PHP_SELF]'>
Email:<br>
<input type='text' name='email' size='30'><br>
Name:<br>
<input type='text' name='name' size='30'><br>
Job:<br>
<select name='job' size='1'>
<option value='Radio manager' value='Radio manager'>Radio Manager (x3)</option>
</select><br>
Do you have any experience at Being a Radio manager, if yes then where?<br>
<textarea name='Any experience?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
Do you currently have a job anywhere, if so where? <br>
<textarea name='Are they working now?' cols='45' rows='2'>EG: Radio manager on www.bobbafm.co.uk</textarea><br>
What sets you aside from all other Applicants?<br>
<textarea name='How are they unique' cols='45' rows='4'>Try and put in as much detail as you can!</textarea><br>
Give me some info about yourself :)<br>
<textarea name='About them' cols='45' rows='5'>Hi my name is bob I am 98 and I am hip hop cooooool</textarea><br>
Why BobbaFM, and what will you bring to BobbaFM?<br>
<textarea name='Why BobbaFM, What will they bring?' cols='45' rows='5'>I would like to work at bobbafm because its new, and I want to contribute to it becoming successful. To do this, I will bring ... (try and do something like that)</textarea><br>
<input type='submit' name='send' value='Submit></form>";
//You can change these values or whatever, have fun.

} //End the last else.
?>

Pazza
19-08-2008, 03:42 PM
Okay,

When I go to www.bobbafm.co.uk/app/radiomanager.php (http://www.bobbafm.co.uk/app/radiomanager.php) it works.

When its in include on http://www.bobbafm.co.uk/app/index.php?p=radiomanager sorry gave wrong link a min ago
(http://www.bobbafm.co.uk/app/index.php?p=radiomanager)
Doesn't work :(

Pazza
19-08-2008, 06:21 PM
Help plz :(

Want to hide these adverts? Register an account for free!