Avatar billede snebold Nybegynder
05. januar 2005 - 20:53 Der er 13 kommentarer og
1 løsning

Mail form problemer

Hej derude.

Er der nogen der kan svare mig på hvorfor det ikke virker?

Jeg får denne fejl;

Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in on line 52

Min kode ser sådan ud; [en smule lang] Håber i vil hjælpe, vil nemlig gerne have den til at virke! Tusind tak!


<html>
<head>
<?php

// your name
$recipientname = "Snakelord Stewart";

// your email
$recipientemail = "hartmann@9kilo.dk";

// subject of the email sent to you
$subject = "Oscar vote by $recipientname";

// send an autoresponse to the user?
$autoresponse = "no";

// subject of autoresponse
$autosubject = "Thank you for your vote!";

// autoresponse message
$automessage = "This is an auto response to let you know that we've successfully received your vote sent through our form. Thanks! We'll get back to you shortly.";

// thankyou displayed after the user clicks "submit"
$thanks = "Thank you for your vote.<br>We will get back to you as soon as possible.<br>";

// END OF NECESSARY MODIFICATIONS

?>

<style type="text/css"><!--
td,body,input,textarea {
    font-size:12px;
    font-family:Verdana,Arial,Helvetica,sans-serif;
    color:#000000}
--></style>
</head>
<body>

<table width="100%" height="100%"><tr>
<td valign="top"><font face="Verdana,Arial,Helvetica" size="2">

<?php
if($_POST['submitform']) {

$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$1 = $HTTP_POST_VARS['1'];
$2 = $HTTP_POST_VARS['2'];
$3 = $HTTP_POST_VARS['3'];
$4 = $HTTP_POST_VARS['4'];
$5 = $HTTP_POST_VARS['5'];
$6 = $HTTP_POST_VARS['6'];
$7 = $HTTP_POST_VARS['7'];
$8 = $HTTP_POST_VARS['8'];
$9 = $HTTP_POST_VARS['9'];
$10 = $HTTP_POST_VARS['10'];
$11 = $HTTP_POST_VARS['11'];
$12 = $HTTP_POST_VARS['12'];
$13 = $HTTP_POST_VARS['13'];
$14 = $HTTP_POST_VARS['14'];
$15 = $HTTP_POST_VARS['15'];
$16 = $HTTP_POST_VARS['16'];
$17 = $HTTP_POST_VARS['17'];
$18 = $HTTP_POST_VARS['18'];
$19 = $HTTP_POST_VARS['19'];
$20 = $HTTP_POST_VARS['20'];
$21 = $HTTP_POST_VARS['21'];
$22 = $HTTP_POST_VARS['22'];
$23 = $HTTP_POST_VARS['23'];
$24 = $HTTP_POST_VARS['24'];
$25 = $HTTP_POST_VARS['25'];
$26 = $HTTP_POST_VARS['26'];
$27 = $HTTP_POST_VARS['27'];
$28 = $HTTP_POST_VARS['28'];
$29 = $HTTP_POST_VARS['29'];
$30 = $HTTP_POST_VARS['30'];
$31 = $HTTP_POST_VARS['31'];



// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}

// check email address
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Invalid email address<br>";}

// display errors
if($error) {
?>

<b>Error</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">try again</a>


<?php
}
else
{

$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;

// format message
$message = "Vote for Oscar by $recipientname:

Ingame Name: $name
Email: $email

Comments: $Comments

Answer on question 1: $1

Answer on question 2: $2

Answer on question 3: $3

Answer on question 4: $4

Answer on question 5: $5

Answer on question 6: $6

Answer on question 7: $7

Answer on question 8: $8

Answer on question 9: $9

Answer on question 10: $10

Answer on question 11: $11

Answer on question 12: $12

Answer on question 13: $13

Answer on question 14: $14

Answer on question 15: $15

Answer on question 16: $16

Answer on question 17: $17

Answer on question 18: $18

Answer on question 19: $19

Answer on question 20: $20

Answer on question 21: $21

Answer on question 22: $22

Answer on question 23: $23

Answer on question 24: $24

Answer on question 25: $25

Answer on question 26: $26

Answer on question 27: $27

Answer on question 28: $28

Answer on question 29: $29

Answer on question 30: $30

Answer on question 31: $31



-----------------------------

Browser: $browser
User IP: $ip";

// send mail and print success message
mail($recipientemail,"$subject","$message","From: $Name <$Email>");

if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}

echo "$thanks";
}
}
else {
?>

<form name="contactform" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="require" value="name,email,subject,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31">
<center>
<b>Voting for "Oscar 2004/2005"</b>
<p>
<b><font color="red">All fields need to be filled!</font></b><p>

<b>Ingame Name:</b> <br> <input id="t1" type="text" name="name"><br />

<b>E-mail:</b>  <br><input id="t2" type="text" name="email"><br />

<b>Subject:</b>  <br><input id="t3" type="text" name="subject" value="Oscar Vote 2004/2005" disabled><br /> <br> <br> <br>


<b>1)</b> Which merchant do you buy from the most? <br><input id="t4" type="text" name="1" /><br />

<b>2)</b> Which merchant offers the best value for money? <br> <input id="t5" type="text" name="2" /><br />

<b>3)</b> Which merchant sells the best items? <br> <input id="t100" type="text" name="3" /><br />

<b>4)</b> Who is the best all round merchant? <br> <input id="t7" type="text" name="4" /><br />

<b>5)</b> Who is the shard's most untrustworthy merchant? <br> <input id="t8" type="text" name="5" /><br />

<b>6)</b> Which is the best warrior guild? <br> <input id="t9" type="text" name="6" /><br />

<b>7)</b> Which is the best merchant guild? <br> <input id="t10" type="text" name="7" /><br />

<b>8)</b> Which is the n00biest guild? <br> <input id="t11" type="text" name="8" /><br />

<b>9)</b> Which guild are most disliked? <br> <input id="t12" type="text" name="9" /><br />

<b>10)</b> Which guild are the biggest gankers? <br> <input id="t13" type="text" name="10" /><br />

<b>11)</b> Who is the all round best player? <br> <input id="t14" type="text" name="11" /><br />

<b>12)</b> Who is the shards biggest houserunner/townrunner? <br> <input id="t15" type="text" name="12" /><br />

<b>13)</b> Who is the shards biggest loser? <br> <input id="t16" type="text" name="13" /><br />

<b>14)</b> Who is the shards friendliest/nicest player? <br> <input id="t17" type="text" name="14" /><br />

<b>15)</b> Who is the shards best mage pvper?  <br><input id="t18" type="text" name="15" /><br />

<b>16)</b> Who is the shards best warrior pvper?  <br><input id="t19" type="text" name="16" /><br />

<b>17)</b> Who is the shards all round best pvper?  <br><input id="t20" type="text" name="17" /><br />

<b>18)</b> Who is the shards biggest looter?  <br><input id="t21" type="text" name="18" /><br />
<b>19)</b> Who is the shards most annoying thief?  <br><input id="t22" type="text" name="19" /><br />

<b>20)</b> Who is the shards biggest scammer?  <br><input id="t23" type="text" name="20" /><br />

<b>21)</b> If you could kick, ban, wipe one player, who would it be?  <br><input id="t24" type="text" name="21" /><br />

<b>22)</b> What is the shard's best player run business? <i>(i.e bar/casino/restaurant) (Name the establishment you like/visit by name such as Rigmoros restaurant etc)</i> <br> <input id="t25" type="text" name="22" /><br />

<b>23)</b> What is the shards best town? <br> <input id="t26" type="text" name="23" /><br />

<b>24)</b> What is the shards best type of tourney?  <br><input id="t27" type="text" name="24" /><br />

<b>25)</b> If you could meet any player in real life, who would it be?  <br><input id="t28" type="text" name="25" /><br />

<b>26)</b> Which country has the best collection of players on the shard? <br> <input id="t29" type="text" name="26" /><br />

<b>27)</b> Who has the shards most nicely decorated house?  <br><input id="t30" type="text" name="27" /><br />

<b>28)</b> What item are you after more than anything else?  <br><input id="t31" type="text" name="28" /><br />

<b>29)</b> What monster is the most worth killing? <br> <input id="t32" type="text" name="29" /><br />

<b>30)</b> What is the best pvm location? <br> <input id="t33" type="text" name="30" /><br />

<b>31)</b> What is the best pvp location? <br> <input id="t34" type="text" name="31" /><br />

<input id="t6" type="submit" name="submitform" value=" Send my votes " />
&nbsp; &nbsp; <input type="reset" value=" Reset everything " />
</form>
<?php } ?>
</font><p></td>
</tr><tr>

</body>
</html>
Avatar billede krydset Nybegynder
05. januar 2005 - 20:59 #1
Som jeg kan se det er fordi du ikke må kalde dine $vars for tal :-S

$1
$2
$3

Osv prøv at ændre dem
Avatar billede jakoba Nybegynder
05. januar 2005 - 21:02 #2
$1 til $30 er ikke lovlige navne til variabler.
navne skal starte med et bogstav fra alfabetet a til z
Avatar billede krydset Nybegynder
05. januar 2005 - 21:04 #3
Okaj så havde jeg da delvis ret :-D, vidste bare ikke årsagen til det, kan du uddybe mere hvorfor man ikke må ?
Avatar billede madsass Nybegynder
05. januar 2005 - 21:18 #4
Jeg har hjulpet snebold over MSN. Vrøvl. Til httpvars må man GODT bruge tal ;)
Avatar billede snebold Nybegynder
05. januar 2005 - 21:19 #5
Madsass, kom med en badass solution. kom bare virker som den skal.

Hvis der er nogen der vil se, som bevis. Kan de altid spørge.
Avatar billede krydset Nybegynder
05. januar 2005 - 21:20 #6
Hey her på eksperten skal svar være tilgængelig for alle og DE MÅ IKKE LØSES UDEN OM
Avatar billede kasperstorm Nybegynder
05. januar 2005 - 21:21 #7
Men det er ikke httpvars det er httpvars der bliver gemt i php vars
Avatar billede snebold Nybegynder
05. januar 2005 - 21:37 #8
Hvis det er sådan, må du godt få 60 point. Men den løsning kunne jeg ikke andet end at tage i mod.
Avatar billede krydset Nybegynder
05. januar 2005 - 21:38 #9
Jeg har hjulpet snebold over MSN. Vrøvl. Til httpvars må man GODT bruge tal ;)


Hvad med at bede ham om at smide en løsning, jeg er s.. ligeglad med point, men vi andre vil godt se hvad der var galt
Avatar billede kasperstorm Nybegynder
05. januar 2005 - 21:46 #10
prøv det her:

<html>
<head>
<?php

// your name
$recipientname = "Snakelord Stewart";

// your email
$recipientemail = "hartmann@9kilo.dk";

// subject of the email sent to you
$subject = "Oscar vote by $recipientname";

// send an autoresponse to the user?
$autoresponse = "no";

// subject of autoresponse
$autosubject = "Thank you for your vote!";

// autoresponse message
$automessage = "This is an auto response to let you know that we've successfully received your vote sent through our form. Thanks! We'll get back to you shortly.";

// thankyou displayed after the user clicks "submit"
$thanks = "Thank you for your vote.<br>We will get back to you as soon as possible.<br>";

// END OF NECESSARY MODIFICATIONS

?>

<style type="text/css"><!--
td,body,input,textarea {
    font-size:12px;
    font-family:Verdana,Arial,Helvetica,sans-serif;
    color:#000000}
--></style>
</head>
<body>

<table width="100%" height="100%"><tr>
<td valign="top"><font face="Verdana,Arial,Helvetica" size="2">

<?php
if(isset($_POST['submitform'])) {

$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$a1 = $HTTP_POST_VARS['1'];
$a2 = $HTTP_POST_VARS['2'];
$a3 = $HTTP_POST_VARS['3'];
$a4 = $HTTP_POST_VARS['4'];
$a5 = $HTTP_POST_VARS['5'];
$a6 = $HTTP_POST_VARS['6'];
$a7 = $HTTP_POST_VARS['7'];
$a8 = $HTTP_POST_VARS['8'];
$a9 = $HTTP_POST_VARS['9'];
$a10 = $HTTP_POST_VARS['10'];
$a11 = $HTTP_POST_VARS['11'];
$a12 = $HTTP_POST_VARS['12'];
$a13 = $HTTP_POST_VARS['13'];
$a14 = $HTTP_POST_VARS['14'];
$a15 = $HTTP_POST_VARS['15'];
$a16 = $HTTP_POST_VARS['16'];
$a17 = $HTTP_POST_VARS['17'];
$a18 = $HTTP_POST_VARS['18'];
$a19 = $HTTP_POST_VARS['19'];
$a20 = $HTTP_POST_VARS['20'];
$a21 = $HTTP_POST_VARS['21'];
$a22 = $HTTP_POST_VARS['22'];
$a23 = $HTTP_POST_VARS['23'];
$a24 = $HTTP_POST_VARS['24'];
$a25 = $HTTP_POST_VARS['25'];
$a26 = $HTTP_POST_VARS['26'];
$a27 = $HTTP_POST_VARS['27'];
$a28 = $HTTP_POST_VARS['28'];
$a29 = $HTTP_POST_VARS['29'];
$a30 = $HTTP_POST_VARS['30'];
$a31 = $HTTP_POST_VARS['31'];



// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}

// check email address
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Invalid email address<br>";}

// display errors
if($error) {
?>

<b>Error</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">try again</a>


<?php
}
else
{

$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;

// format message
$message = "Vote for Oscar by $recipientname:

Ingame Name: $name
Email: $email

Comments: $Comments

Answer on question 1: $a1

Answer on question 2: $a2

Answer on question 3: $a3

Answer on question 4: $a4

Answer on question 5: $a5

Answer on question 6: $a6

Answer on question 7: $a7

Answer on question 8: $a8

Answer on question 9: $a9

Answer on question 10: $a10

Answer on question 11: $a11

Answer on question 12: $a12

Answer on question 13: $a13

Answer on question 14: $a14

Answer on question 15: $a15

Answer on question 16: $a16

Answer on question 17: $a17

Answer on question 18: $a18

Answer on question 19: $a19

Answer on question 20: $a20

Answer on question 21: $a21

Answer on question 22: $a22

Answer on question 23: $a23

Answer on question 24: $a24

Answer on question 25: $a25

Answer on question 26: $a26

Answer on question 27: $a27

Answer on question 28: $a28

Answer on question 29: $a29

Answer on question 30: $a30

Answer on question 31: $a31



-----------------------------

Browser: $browser
User IP: $ip";

// send mail and print success message
mail($recipientemail,"$subject","$message","From: $Name <$Email>");

if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}

echo "$thanks";
}
}
else {
?>

<form name="contactform" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="require" value="name,email,subject,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31">
<center>
<b>Voting for "Oscar 2004/2005"</b>
<p>
<b><font color="red">All fields need to be filled!</font></b><p>

<b>Ingame Name:</b> <br> <input id="t1" type="text" name="name"><br />

<b>E-mail:</b>  <br><input id="t2" type="text" name="email"><br />

<b>Subject:</b>  <br><input id="t3" type="text" name="subject" value="Oscar Vote 2004/2005" disabled><br /> <br> <br> <br>


<b>1)</b> Which merchant do you buy from the most? <br><input id="t4" type="text" name="1" /><br />

<b>2)</b> Which merchant offers the best value for money? <br> <input id="t5" type="text" name="2" /><br />

<b>3)</b> Which merchant sells the best items? <br> <input id="t100" type="text" name="3" /><br />

<b>4)</b> Who is the best all round merchant? <br> <input id="t7" type="text" name="4" /><br />

<b>5)</b> Who is the shard's most untrustworthy merchant? <br> <input id="t8" type="text" name="5" /><br />

<b>6)</b> Which is the best warrior guild? <br> <input id="t9" type="text" name="6" /><br />

<b>7)</b> Which is the best merchant guild? <br> <input id="t10" type="text" name="7" /><br />

<b>8)</b> Which is the n00biest guild? <br> <input id="t11" type="text" name="8" /><br />

<b>9)</b> Which guild are most disliked? <br> <input id="t12" type="text" name="9" /><br />

<b>10)</b> Which guild are the biggest gankers? <br> <input id="t13" type="text" name="10" /><br />

<b>11)</b> Who is the all round best player? <br> <input id="t14" type="text" name="11" /><br />

<b>12)</b> Who is the shards biggest houserunner/townrunner? <br> <input id="t15" type="text" name="12" /><br />

<b>13)</b> Who is the shards biggest loser? <br> <input id="t16" type="text" name="13" /><br />

<b>14)</b> Who is the shards friendliest/nicest player? <br> <input id="t17" type="text" name="14" /><br />

<b>15)</b> Who is the shards best mage pvper?  <br><input id="t18" type="text" name="15" /><br />

<b>16)</b> Who is the shards best warrior pvper?  <br><input id="t19" type="text" name="16" /><br />

<b>17)</b> Who is the shards all round best pvper?  <br><input id="t20" type="text" name="17" /><br />

<b>18)</b> Who is the shards biggest looter?  <br><input id="t21" type="text" name="18" /><br />
<b>19)</b> Who is the shards most annoying thief?  <br><input id="t22" type="text" name="19" /><br />

<b>20)</b> Who is the shards biggest scammer?  <br><input id="t23" type="text" name="20" /><br />

<b>21)</b> If you could kick, ban, wipe one player, who would it be?  <br><input id="t24" type="text" name="21" /><br />

<b>22)</b> What is the shard's best player run business? <i>(i.e bar/casino/restaurant) (Name the establishment you like/visit by name such as Rigmoros restaurant etc)</i> <br> <input id="t25" type="text" name="22" /><br />

<b>23)</b> What is the shards best town? <br> <input id="t26" type="text" name="23" /><br />

<b>24)</b> What is the shards best type of tourney?  <br><input id="t27" type="text" name="24" /><br />

<b>25)</b> If you could meet any player in real life, who would it be?  <br><input id="t28" type="text" name="25" /><br />

<b>26)</b> Which country has the best collection of players on the shard? <br> <input id="t29" type="text" name="26" /><br />

<b>27)</b> Who has the shards most nicely decorated house?  <br><input id="t30" type="text" name="27" /><br />

<b>28)</b> What item are you after more than anything else?  <br><input id="t31" type="text" name="28" /><br />

<b>29)</b> What monster is the most worth killing? <br> <input id="t32" type="text" name="29" /><br />

<b>30)</b> What is the best pvm location? <br> <input id="t33" type="text" name="30" /><br />

<b>31)</b> What is the best pvp location? <br> <input id="t34" type="text" name="31" /><br />

<input id="t6" type="submit" name="submitform" value=" Send my votes " />
&nbsp; &nbsp; <input type="reset" value=" Reset everything " />
</form>
<?php } ?>
</font><p></td>
</tr><tr>

</body>
</html>
Avatar billede jakoba Nybegynder
05. januar 2005 - 22:33 #11
Hvorfor php-navne sjal begynde med et bogstav:
1) fordi maualen siger det: anden paragraf i http://dk.php.net/manual/en/language.variables.php
"    Variable names follow the same rules as other labels in PHP. A valid
    variable name starts with a letter or underscore, followed by any number
    of letters, numbers, or underscores. As a regular expression, it would
    be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
"
2) fordi programkoden skal læses og forstås af en computer, og helst så hurtigt som muligt. Hnis man kan stole på at første tegn i navnet altid er et bogstav kan man se hvad der kommer efterhånden som man læser bogstaver fra filen
  12345      // såsnart php læser '1'-et ved den der kommer et tal nu
  a1234      // såsnart php læser 'a'-et ved den der kommer et navn nu
hvis reglen ikke var der kunne vi risikere:
  123m45hest  // hvis det var et lovligt navn skulle php kunne ombestemme sig midtvejs i ordet (efter '123') og sige "næe, det ma da være et navn" og så læse det forfra. Det ville gøre fortolkningen en del langsommere.

Det er korrekt at de store browsere tillader ID og NAME værdier at være tal. men HTML specifikationen tillader det faktisk ikke:
http://www.w3.org/TR/html4/types.html#type-name
"    # ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
    followed by any number of letters, digits ([0-9]), hyphens ("-"),
    underscores ("_"), colons (":"), and periods (".").
"
Det giver også en del problemer hvis man i websiden ønsker at adressere navngivne elementer med javascript.

en HTTPvar er et navn sendt over http (fx i en parameterliste), og ja de må gerne bestå af cifre.

Og i og med at de navne der bruges her faktisk skal bruges 3 forskellige steder: i browseren, i dataoverførselen via http, og i php ville jeg til enhver tid anbefale at vælge navne der er lovlige og kan benyttes alle 3 steder.

mvh JakobA
Avatar billede kasperstorm Nybegynder
05. januar 2005 - 22:36 #12
Så er det vist på plads ;)
Avatar billede madsass Nybegynder
06. januar 2005 - 07:23 #13
Krydset. Jeg lavede en helt anden formular og sendte til ham. Derfor brugte vi ikke denne.
Avatar billede krydset Nybegynder
06. januar 2005 - 08:55 #14
Det er fuldstændig ligemeget, du skriver herinde at spm er løst "udenom" eksperten via msn, ergo er spm blevet løst, men svaret er ikke alle tilgængelig. Og det skal det være herinde
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester