Help - Search - Members - Calendar
Full Version: PHP Form
Suggest A Fix PC Support Forums > Internet > Server-Side Coding
crazy_blue
Umm... I Tried To Make This Form Work, But For Some Reason On The Bottom Status Bar It Says Done But With Error And When You Click Submit It Says
QUOTE
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /var/www/html/join.php on line 23
Anyone Has Any Ideas Why And How It Can Be Fixed? You Can Check The Form Here crazy-blue.net/join Any Help Is Appreciated. Thanks
Robert Wellock
It's hardly surprising, for the JavaScript issue remove:
CODE
ONLOAD="preloadImages();"


The other is a PHP issue which I couldn't see myself.
crazy_blue
Do You, By Any Chance, See Anything Wrong With This...?

CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Crazy Blue  |  crazy-blue.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
if(!isset($email)||!isset($message)){
  header("Location: http://crazy-blue.net/join.php");
}
if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
."@([a-z0-9]+([\.-][a-z0-9]+))*$",
$email, $regs) )
{
  header("Location: http://crazy-blue.net/error.php");
}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
  header("Location: http://crazy-blue.net/error.php");
}
else if (empty($user_name) || empty($password) || empty($con_password) || empty($hint) || empty($email) || empty($con_email) || empty($first_name) || empty($last_name) || empty($sex) || empty($age) || empty($sexuality) || empty($status) || empty($city) || empty($postal) || empty($province) || empty($country) || empty($photo01) || empty($)photo02) || empty($description) || empty($turn_ons) || empty($turn_offs)){
  header("Location: http://crazy-blue.neterror.php");
}
else{
  mail( "admin@crazy-blue.net", "Application to Join",

  "User Name: $name\n
  Password: $password\n
  Confirm Password: $con_password\n
  Password Hint: $hint\n
  E-Mail: <$email>\n
  Confirm E-Mail: <$con_email>\n
  First Name: $first_name\n
  Last Name: $last_name\n
  Sex: $sex\n
  Age: $age\n
  Sexuality: $sexuality\n
  Status: $status\n
  City: $city\n
  Postal: $postal\n
  Province: $province\n
  Country: $country\n
  Photo01: $photo01\n
  Photo02: $photo02\n
  Photo03: $photo03\n
  Photo04: $photo04\n
  Photo05: $photo05\n
  Photo06: $photo06\n
  Photo07: $photo07\n
  Photo08: $photo08\n
  Photo09: $photo09\n
  Photo10: $photo10\n
  Description: $description\n
  Turn Ons: $turn_ons\n
  Turn Offs: $turn_offs\n
  ");

  header( "Location: http://crazy-blue.net/thanks.php" );
}
?>
</body>
</html>


Please Help, Thanks!
Angoid
Looks like it's this line that is failing:-

CODE
else if (empty($user_name) || empty($password) || empty($con_password) || empty($hint) || empty($email) || empty($con_email) || empty($first_name) || empty($last_name) || empty($sex) || empty($age) || empty($sexuality) || empty($status) || empty($city) || empty($postal) || empty($province) || empty($country) || empty($photo01) || empty($)photo02) || empty($description) || empty($turn_ons) || empty($turn_offs)){


It's this that's doing it:

CODE
empty($)photo02


Take the close bracket out after the dollar sign, and you'll be OK:-

CODE
else if (empty($user_name) || empty($password) || empty($con_password) || empty($hint) || empty($email) || empty($con_email) || empty($first_name) || empty($last_name) || empty($sex) || empty($age) || empty($sexuality) || empty($status) || empty($city) || empty($postal) || empty($province) || empty($country) || empty($photo01) || empty($photo02) || empty($description) || empty($turn_ons) || empty($turn_offs)){


To find it, I simply pasted it into a vi session in Unix, positioned the cursor over the first open bracket, and gave the percent command. This finds the corresponding closing bracket, and it went to the offending close bracket.

After removing it, I repeated the exercise and this time I was taken to the end of the IF (before the open curly) - exactly where I expected to go!

Hope that helps!
crazy_blue
thanks... smile.gif
crazy_blue
Umm... When I Filled Up The Form Myself To See If It Works Or Not I Got This Error

QUOTE

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/join.php:9) in /var/www/html/join.php on line 11

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/join.php:9) in /var/www/html/join.php on line 60


I Did Get The Results, Right, But I Didn't Get The Pics... blink.gif
colhutch
line 11 and line 60 have white space characters. Generally a tab. You get this message when php writes something prior to a header call.

Get rid of the tab or anything that may print to screen at lines 11 and 60 should fix that problem
crazy_blue
Anyone Sees Any Problem With This...

CODE
<?php
if(!isset($email)||!isset($message))
{
  header("Location: http://crazy-blue.net/join/join.php");
}
if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
."@([a-z0-9]+([\.-][a-z0-9]+))*$",
$email, $regs) )
{
  header("Location: http://crazy-blue.net/join/error.php");
}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
  header("Location: http://crazy-blue.net/join/error.php");
}
else if (empty($user_name) || empty($password) || empty($con_password) || empty($hint) || empty($email) || empty($con_email) || empty($first_name) || empty($last_name) || empty($sex) || empty($age) || empty($sexuality) || empty($status) || empty($city) || empty($postal) || empty($province) || empty($country) || empty($photo01) || empty($photo02) || empty($description) || empty($turn_ons) || empty($turn_offs)){
  header("Location: http://crazy-blue.net/join/error.php");
}
else{
  mail( "admin@crazy-blue.net", "Application to Join",

  "User Name: $name\n
  Password: $password\n
  Confirm Password: $con_password\n
  Password Hint: $hint\n
  E-Mail: <$email>\n
  Confirm E-Mail: <$con_email>\n
  First Name: $first_name\n
  Last Name: $last_name\n
  Sex: $sex\n
  Age: $age\n
  Sexuality: $sexuality\n
  Status: $status\n
  City: $city\n
  Postal: $postal\n
  Province: $province\n
  Country: $country\n
  Photo01: $photo01\n
  Photo02: $photo02\n
  Photo03: $photo03\n
  Photo04: $photo04\n
  Photo05: $photo05\n
  Photo06: $photo06\n
  Photo07: $photo07\n
  Photo08: $photo08\n
  Photo09: $photo09\n
  Photo10: $photo10\n
  Description: $description\n
  Turn Ons: $turn_ons\n
  Turn Offs: $turn_offs\n
  ");
 
  header("Location: http://crazy-blue.net/join/thanks.php");
}
?>


I Just Don't See Anything Wrong But I Keep Getting This Error Now...

QUOTE
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/join/join.php:9) in /var/www/html/join/join.php on line 12

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/join/join.php:9) in /var/www/html/join/join.php on line 61


One More Thing. How Come I Don't Get The Pics? I Get All The Text, But Where The Pics Are Suppose To Be, It Says...

QUOTE

  Photo01: /tmp/php3c62Rm

  Photo02: /tmp/phpsdOzrw


Any Ideas? Thanks For The Help...
Angoid
You get the "headers already sent" error because the declaration of the document, the HTML Head section, etc, sends headers. After this, use of the header() PHP function is not defined to work.

You need to rearrange the code to look a bit more like this....

CODE
<?php
if(!isset($email)||!isset($message)){
 header("Location: http://crazy-blue.net/join.php");
}
if( !eregi("^[a-z0-9]+([_\.-][a-z0-9]+)*"
."@([a-z0-9]+([\.-][a-z0-9]+))*$",
$email, $regs) )
{
 header("Location: http://crazy-blue.net/error.php");
}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
 header("Location: http://crazy-blue.net/error.php");
}
else if (empty($user_name) || empty($password) || empty($con_password) || empty($hint) || empty($email) || empty($con_email) || empty($first_name) || empty($last_name) || empty($sex) || empty($age) || empty($sexuality) || empty($status) || empty($city) || empty($postal) || empty($province) || empty($country) || empty($photo01) || empty($)photo02) || empty($description) || empty($turn_ons) || empty($turn_offs)){
 header("Location: http://crazy-blue.neterror.php");
}
else{
 mail( "admin@crazy-blue.net", "Application to Join",

 "User Name: $name\n
 Password: $password\n
 Confirm Password: $con_password\n
 Password Hint: $hint\n
 E-Mail: <$email>\n
 Confirm E-Mail: <$con_email>\n
 First Name: $first_name\n
 Last Name: $last_name\n
 Sex: $sex\n
 Age: $age\n
 Sexuality: $sexuality\n
 Status: $status\n
 City: $city\n
 Postal: $postal\n
 Province: $province\n
 Country: $country\n
 Photo01: $photo01\n
 Photo02: $photo02\n
 Photo03: $photo03\n
 Photo04: $photo04\n
 Photo05: $photo05\n
 Photo06: $photo06\n
 Photo07: $photo07\n
 Photo08: $photo08\n
 Photo09: $photo09\n
 Photo10: $photo10\n
 Description: $description\n
 Turn Ons: $turn_ons\n
 Turn Offs: $turn_offs\n
 ");

 header( "Location: http://crazy-blue.net/thanks.php" );
}
?>


In other words, take out ALL the HTML because it's simply not needed!

As for the pictures, I think this is because you're outputting the actual text rather than the actual picture itself. You may need to use anothe PHP function to encode the image data into the e-mail itself if this is what you're trying to achieve. But I can't remember offhand what that function is.

This may help - Send is a great source of PHP information.

Be aware though that if that't the case you could be creating some huge e-mails for yourself!

Hope this helps!
crazy_blue
ey... it worked. finally biggrin.gif thanks everyone. now i just need to figure out how to get the pictures to show up! blink.gif LOL
Angoid
Glad you got it working keybrd.gif

Another thought on the photos - you've got a straight-line list of 10 which might, in time, prove inflexible. If this project is still in its infancy it may be worth considering using a loop, and if there's a database table take the "repeating groups" out. This will provide for as few or as many photos as are required.

So, instead of this....

CODE
member_id
member_name
...
...
turnoffs
photo1
photo2
photo3
photo4
...
...
photo10


have two tables:

CODE
member_id
member_name
...
...
turnoffs

(member_id is a unique key)

CODE
member_id
photo_number
photoname

(member, photo_number is a unique key)

That may seem a lot of work for now, but when you need to have one more photo than you currently allow, you'll reap the benefits! We call this reducing data to Third Normal Form where the data is "dependent on the key, the whole key, and nothing but the key".

As for getting the photos to work, you'll probably need to use MIME (Multipart Internet Mail Extensions) as the PHP mail() command will otherwise only send plain text. That's why you got the paths to the photos coming out instead of the actual pictures themselves. This is an area I have yet to play with, but that Zend article in my earlier post should help you there.
crazy_blue
Umm... okay, I figured out where to change the part about the whole "multipart/mixed" thing. but it's still not showing up the pics. isn't the code suppose to go between <head> </head>? and look something like
CODE
<META http-equiv="Content-Type" content="multipart/mixed; charset=ISO-8859-1">
? and to make sure, this does goes in the .html file and not the php one, right? sorry for being so annoying, i'm just new to php...
crazy_blue
LOL. okay honestly... i have no idea what you said about the whole member_id thing. it's like you're talking in some language of which i only know the alphabets but don't know how to put them together. wacko.gif
Angoid
QUOTE
Umm... okay, I figured out where to change the part about the whole "multipart/mixed" thing. but it's still not showing up the pics. isn't the code suppose to go between <head> </head>? and look something like
CODE

<META http-equiv="Content-Type" content="multipart/mixed; charset=ISO-8859-1">

? and to make sure, this does goes in the .html file and not the php one, right? sorry for being so annoying, i'm just new to php...


You'd put that into the string you build up that will form the body of the e-mail message.

See the following resources for the mail() function:-

PHP.net mail() article
ZEND article linked from the one at php.net

QUOTE
LOL. okay honestly... i have no idea what you said about the whole member_id thing. it's like you're talking in some language of which i only know the alphabets but don't know how to put them together.


It doesn't matter if that didn't mean much to you .... all I was trying to do was advise against using a list of names such as photo01, photo02, photo03, etc. and instead form a flexible repeating group that would allow as few or as many photos as required. This would allow for future expansion without any code change. But if there is no requirement for this, either now or in the future, then stick to what you've got as it'll do the job.
crazy_blue
it's not that it didn't matter to me, it's that i don't understand it. i'm just trying to figure out what goes where and trying to finish this form as quick as possible but i don't want to get into that much detailing. i went to the site like you told me, but it's totally different from what i have. it tells me some other stuff that i'm not fimiliar with... all i wanted was to get my images to show up when the form was submitted, but the stuff that they're teaching on the sites provided is... i don't even have a word for it. cry.gif

CODE

<?php
if(!isset($email)||!isset($message)){
header("Location: http://crazy-blue.net/join/join.php");
}
if( !eregi("^[a-z0-9]+([_\.-][a-z0-9]+)*"
."@([a-z0-9]+([\.-][a-z0-9]+))*$",
$email, $regs) )
{
header("Location: http://crazy-blue.net/join/error.php");
}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
header("Location: http://crazy-blue.net/join/error.php");
}
else if (empty($user_name) || empty($password) || empty($con_password) || empty($hint) || empty($email) || empty($con_email) || empty($first_name) || empty($last_name) || empty($sex) || empty($age) || empty($sexuality) || empty($status) || empty($city) || empty($postal) || empty($province) || empty($country) || empty($photo01) || empty($photo02) || empty($description) || empty($turn_ons) || empty($turn_offs)){
header("Location: http://crazy-blue.net/join/error.php");
}
else{
mail( "admin@crazy-blue.net", "Application to Join",

"User Name: $name\n
Password: $password\n
Confirm Password: $con_password\n
Password Hint: $hint\n
E-Mail: <$email>\n
Confirm E-Mail: <$con_email>\n
First Name: $first_name\n
Last Name: $last_name\n
Sex: $sex\n
Age: $age\n
Sexuality: $sexuality\n
Status: $status\n
City: $city\n
Postal: $postal\n
Province: $province\n
Country: $country\n
Photo01: $photo01\n
Photo02: $photo02\n
Photo03: $photo03\n
Photo04: $photo04\n
Photo05: $photo05\n
Photo06: $photo06\n
Photo07: $photo07\n
Photo08: $photo08\n
Photo09: $photo09\n
Photo10: $photo10\n
Description: $description\n
Turn Ons: $turn_ons\n
Turn Offs: $turn_offs\n
");

header( "Location: http://crazy-blue.net/join/thanks.php" );
}
?>


one young php ignorant kid in need of SERIOUS help.
Raymond
sorry wrong topic :o
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.