Avatar billede partyguiden Nybegynder
24. september 2001 - 10:50 Der er 11 kommentarer

Hvad er der galt her!

Hvad er der galt her:
<html>
<head>
<title>PHPCards - Version 0.2</title>
</head>
<body>

<?php
          $cardfile= \"cards/cardfile.txt\";            // Text file for saving cards

  // Counter Script
$free=0;
$empty= \"empty\\n\";
$oldcards = file($cardfile);
$total = count($oldcards);
for($i = 0 ; $i < count($oldcards) ; $i++) {
if($array[$i] == $empty) {
$free=$i;
}
}
if($free== \"0\"){
if($oldcards==$empty){
$free=0;
}
else {
$free=$total;
}
}

  // Place existing cards into an array.
$fd = fopen( \"$cardfile\",  \"r\");
$oldcards =  \"\";        // Leave this blank 
    while ($buffer = fgets($fd, 4096)) {
    $oldcards .= $buffer;
}
fclose($fd);

// Change Text so that it doesn\'t interfere with messages
$message = str_replace( \":\",chr(0),$message);              // Colon to null character
$message = str_replace( \"  \", \" \",$message);        // Double Space to HTML Space ( ) 
$remail = str_replace( \":\",chr(0),$remail);           
$recipient = str_replace( \":\",chr(0),$recipient);           
$semail = str_replace( \":\",chr(0),$semail);           
$sender = str_replace( \":\",chr(0),$sender);           

// Generate a Random Number - Security
srand((double)microtime()*1000000);            // Random Seed   
$random = rand(1000,9000);                        // Range (between 1000-9000)

  // What is written to the Text File
$newcard = $free+1 .  \":\" . $picture .  \":\" . nl2br(htmlentities($remail)) .  \":\" . nl2br(htmlentities($recipient)) .  \":\" . nl2br(htmlentities($semail)) .  \":\" . nl2br(htmlentities($sender)) .  \":\" . eregi_replace( \"\\n\",  \"<br>\", $message ) .  \":\" . $random .  \"\\n\";   

$allcards = $oldcards . $newcard;
$idnumber=$free+1;

  // If the recipient\'s email is correct
if (eregi( \"^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*$\", $remail)) { 
                 
  // Preview Message

echo  \"<table BORDER=0 WIDTH=\\\"100%\\\">\\n<tr>\\n<td ALIGN=CENTER VALIGN=TOP>\\n<IMG src=\\\"$picture\\\">\\n</td>\\n \";
echo  \"<td VALIGN=TOP>\\n<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH=\\\"100%\\\">\\n<tr>\\n<td>\\n<b>To:</b>\\n</td>\\n<td>\\n<a href=\\\"mailto:$remail\\\">\";
echo stripslashes(htmlentities($recipient))  .  \"</a>\\n</td>\\n</tr>\\n\";
echo  \"<tr>\\n<td>\\n<b>From:</b></td>\\n<td>\\n<a href=\\\"mailto:$semail\\\">\";
echo stripslashes(htmlentities($sender))  .  \"</a>\\n</td>\\n</tr>\\n</table>\\n\";
echo  \"<B>Message:</B><BR>\" . stripslashes(nl2br(htmlentities($message)))  .  \"</td>\\n</td>\\n</tr>\\n</table>\\n\";

  // If the sender\'s email is correct
if (eregi( \"^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*$\", $semail)) {

if ($epost ==  \"yes\") {    // Write to file
$cartFile = fopen( \"$cardfile\", \"w\");
fwrite($cartFile,$allcards);
fclose($cartFile);


  // Message to be included in email
 
$email_message =  \"For at hente dit kort, så besøg:

HTTP://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\"




The Message Text Follows:
\" . eregi_replace( \"<br>\",  \"\\n\",stripslashes($message));


  // Send to recipient  - Taken Out: Reply-To: $semail \\r\\n X-Mailer: PHP3 \\r\\n 
mail(stripslashes($recipient) .  \"<$remail>\", stripslashes($sender) .  \" has sent you a card\", $email_message, \"From: $semail \\nReply-To:$semail\\nX-Mailer: PHP3\\r\\n Errors-To: mike@flora.org\");

// To send another card
echo  \"<P><hr width=\\\"50%\\\"><P>Your card number $idnumber has been sent to \" . stripslashes($recipient);
echo  \"<p>\\n<strong>Would you like to send another card?</strong><p>\\n\";
echo  \"<form method=\\\"GET\\\" action=\\\"send.phtml\\\">\";
echo  \"<input type=\\\"radio\\\" value=\\\"yes\\\" NAME=\\\"epost\\\">Yes, please!\";
echo  \"<input type=\\\"radio\\\" value=\\\"no\\\" NAME=\\\"epost\\\">No, thank you.\";
echo  \"<input type=hidden name=\\\"remail\\\" value=\\\"$remail\\\">\";
echo  \"<input type=hidden name=\\\"recipient\\\" value=\\\"\" . stripslashes(htmlentities($recipient)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"semail\\\" value=\\\"$semail\\\">\";
echo  \"<input type=hidden name=\\\"sender\\\" value=\\\"\" . stripslashes(htmlentities($sender)) .  \"\\\">\";
echo  \"<input type=\\\"submit\\\" value=\\\"Submit\\\"></form><br>\";

}
elseif ($epost ==  \"no\") {

echo  \"<P><hr width=\\\"50%\\\"><P><strong>Would you like to try again?</strong><p>\\n\";
echo  \"<form method=\\\"GET\\\" action=\\\"send.phtml\\\">\";
echo  \"<input type=\\\"radio\\\" value=\\\"yes\\\" NAME=\\\"epost\\\">Yes, please!\";
echo  \"<input type=\\\"radio\\\" value=\\\"no\\\" NAME=\\\"epost\\\">No, thank you.\";
echo  \"<input type=hidden name=\\\"picture\\\" value=\\\"$picture\\\">\";
echo  \"<input type=hidden name=\\\"remail\\\" value=\\\"$remail\\\">\";
echo  \"<input type=hidden name=\\\"recipient\\\" value=\\\"\" . stripslashes(htmlentities($recipient)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"semail\\\" value=\\\"$semail\\\">\";
echo  \"<input type=hidden name=\\\"sender\\\" value=\\\"\" . stripslashes(htmlentities($sender)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"message\\\" value=\\\"\" . stripslashes(htmlentities($message)) .  \"\\\">\";
echo  \"<input type=\\\"submit\\\" value=\\\"Submit\\\"></form><br>\";

}

else  {

echo  \"<P><hr width=\\\"50%\\\"><P><strong>You have not YET sent the card.</strong><p>\\n\";
echo  \"<form method=\\\"GET\\\" action=\\\"send.php3\\\">\";
echo  \"<input type=\\\"radio\\\" value=\\\"yes\\\" NAME=\\\"epost\\\">Yes, please send my card!\";
echo  \"<input type=\\\"radio\\\" value=\\\"no\\\" NAME=\\\"epost\\\">No thank you.\";
echo  \"<input type=hidden name=\\\"picture\\\" value=\\\"$picture\\\">\";
echo  \"<input type=hidden name=\\\"remail\\\" value=\\\"$remail\\\">\";
echo  \"<input type=hidden name=\\\"recipient\\\" value=\\\"\" . stripslashes(htmlentities($recipient)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"semail\\\" value=\\\"$semail\\\">\";
echo  \"<input type=hidden name=\\\"sender\\\" value=\\\"\" . stripslashes(htmlentities($sender)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"message\\\" value=\\\"\" . stripslashes(htmlentities($message)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"idnumber\\\" value=\\\"$idnumber\\\">\";
echo  \"<input type=hidden name=\\\"\\\" value=\\\"$\\\">\";
echo  \"<input type=\\\"submit\\\" value=\\\"Submit\\\"></form><br>\";

}

}          // End of verification for $semail
else { echo  \"<strong>This card was NOT sent because a valid email address was not provided!</strong><p>\\n\"; }

}          // End of verification for $remail
else { echo  \"<strong>A preview was NOT provided because a valid email address was not provided!</strong><p>\\n\"; }

?>

</body>
</html>

Fejlen er: Parse error: parse error in send.php3 on line 85
Avatar billede Slettet bruger
24. september 2001 - 10:54 #1
$email_message =  \"For at hente dit kort, så besøg:

HTTP://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\"




The Message Text Follows:
\" . eregi_replace( \"<br>\",  \"\\n\",stripslashes($message));

ligner noget rod..
Avatar billede limemedia Nybegynder
24. september 2001 - 10:55 #2
istedet for
$email_message =  \"For at hente dit kort, så besøg:

HTTP://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\"




The Message Text Follows:
\" . eregi_replace( \"<br>\",  \"\\n\",stripslashes($message));

kan du lave
$email_message = \"For at hente dit kort, så besøg:\\n\\n\";
$email_message .= \"http://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\\n\\n\";
$email_message = \"The Message Text Follows:\\n\".stripslashes(nl2br($message)));

og undervejs vil du opdage der har indsneget sig et \" for meget efter $random i
HTTP://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\"
Avatar billede Slettet bruger
24. september 2001 - 10:55 #3
$email_message =  \"For at hente dit kort, så besøg: HTTP://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\"
// The Message Text Follows:
\" . eregi_replace( \"<br>\",  \"\\n\",stripslashes($message));

er nok bedre...
Avatar billede limemedia Nybegynder
24. september 2001 - 10:59 #4
ups, den vender jo forkert... men skal også være .= :)

$email_message = \"For at hente dit kort, så besøg:\\n\\n\";
$email_message .= \"http://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\\n\\n\";
$email_message .= \"The Message Text Follows:\\n\".eregi_replace(\"<br>\",\"\\n\",stripslashes($message));
Avatar billede partyguiden Nybegynder
24. september 2001 - 11:49 #5
Kan det passe hele koden er:
<html>
<head>
<title>PHPCards - Version 0.2</title>
</head>
<body>

<?php
          $cardfile= \"cards/cardfile.txt\";            // Text file for saving cards

  // Counter Script
$free=0;
$empty= \"empty\\n\";
$oldcards = file($cardfile);
$total = count($oldcards);
for($i = 0 ; $i < count($oldcards) ; $i++) {
if($array[$i] == $empty) {
$free=$i;
}
}
if($free== \"0\"){
if($oldcards==$empty){
$free=0;
}
else {
$free=$total;
}
}

  // Place existing cards into an array.
$fd = fopen( \"$cardfile\",  \"r\");
$oldcards =  \"\";        // Leave this blank 
    while ($buffer = fgets($fd, 4096)) {
    $oldcards .= $buffer;
}
fclose($fd);

// Change Text so that it doesn\'t interfere with messages
$message = str_replace( \":\",chr(0),$message);              // Colon to null character
$message = str_replace( \"  \", \" \",$message);        // Double Space to HTML Space ( ) 
$remail = str_replace( \":\",chr(0),$remail);           
$recipient = str_replace( \":\",chr(0),$recipient);           
$semail = str_replace( \":\",chr(0),$semail);           
$sender = str_replace( \":\",chr(0),$sender);           

// Generate a Random Number - Security
srand((double)microtime()*1000000);            // Random Seed   
$random = rand(1000,9000);                        // Range (between 1000-9000)

  // What is written to the Text File
$newcard = $free+1 .  \":\" . $picture .  \":\" . nl2br(htmlentities($remail)) .  \":\" . nl2br(htmlentities($recipient)) .  \":\" . nl2br(htmlentities($semail)) .  \":\" . nl2br(htmlentities($sender)) .  \":\" . eregi_replace( \"\\n\",  \"<br>\", $message ) .  \":\" . $random .  \"\\n\";   

$allcards = $oldcards . $newcard;
$idnumber=$free+1;

  // If the recipient\'s email is correct
if (eregi( \"^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*$\", $remail)) { 
                 
  // Preview Message

echo  \"<table BORDER=0 WIDTH=\\\"100%\\\">\\n<tr>\\n<td ALIGN=CENTER VALIGN=TOP>\\n<IMG src=\\\"$picture\\\">\\n</td>\\n \";
echo  \"<td VALIGN=TOP>\\n<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH=\\\"100%\\\">\\n<tr>\\n<td>\\n<b>To:</b>\\n</td>\\n<td>\\n<a href=\\\"mailto:$remail\\\">\";
echo stripslashes(htmlentities($recipient))  .  \"</a>\\n</td>\\n</tr>\\n\";
echo  \"<tr>\\n<td>\\n<b>From:</b></td>\\n<td>\\n<a href=\\\"mailto:$semail\\\">\";
echo stripslashes(htmlentities($sender))  .  \"</a>\\n</td>\\n</tr>\\n</table>\\n\";
echo  \"<B>Message:</B><BR>\" . stripslashes(nl2br(htmlentities($message)))  .  \"</td>\\n</td>\\n</tr>\\n</table>\\n\";

  // If the sender\'s email is correct
if (eregi( \"^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*$\", $semail)) {

if ($epost ==  \"yes\") {    // Write to file
$cartFile = fopen( \"$cardfile\", \"w\");
fwrite($cartFile,$allcards);
fclose($cartFile);


  // Message to be included in email
 
$email_message = \"For at hente dit kort, så besøg:\\n\\n\";
$email_message .= \"http://pg.whitehat.dk/cards/receive.php3?viewcard=$idnumber&random=$random\\n\\n\";
$email_message .= \"The Message Text Follows:\\n\".eregi_replace(\"<br>\",\"\\n\",stripslashes($message));
  // Send to recipient  - Taken Out: Reply-To: $semail \\r\\n X-Mailer: PHP3 \\r\\n 
mail(stripslashes($recipient) .  \"<$remail>\", stripslashes($sender) .  \" has sent you a card\", $email_message, \"From: $semail \\nReply-To:$semail\\nX-Mailer: PHP3\\r\\n Errors-To: mike@flora.org\");

// To send another card
echo  \"<P><hr width=\\\"50%\\\"><P>Your card number $idnumber has been sent to \" . stripslashes($recipient);
echo  \"<p>\\n<strong>Would you like to send another card?</strong><p>\\n\";
echo  \"<form method=\\\"GET\\\" action=\\\"send.phtml\\\">\";
echo  \"<input type=\\\"radio\\\" value=\\\"yes\\\" NAME=\\\"epost\\\">Yes, please!\";
echo  \"<input type=\\\"radio\\\" value=\\\"no\\\" NAME=\\\"epost\\\">No, thank you.\";
echo  \"<input type=hidden name=\\\"remail\\\" value=\\\"$remail\\\">\";
echo  \"<input type=hidden name=\\\"recipient\\\" value=\\\"\" . stripslashes(htmlentities($recipient)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"semail\\\" value=\\\"$semail\\\">\";
echo  \"<input type=hidden name=\\\"sender\\\" value=\\\"\" . stripslashes(htmlentities($sender)) .  \"\\\">\";
echo  \"<input type=\\\"submit\\\" value=\\\"Submit\\\"></form><br>\";

}
elseif ($epost ==  \"no\") {

echo  \"<P><hr width=\\\"50%\\\"><P><strong>Would you like to try again?</strong><p>\\n\";
echo  \"<form method=\\\"GET\\\" action=\\\"send.phtml\\\">\";
echo  \"<input type=\\\"radio\\\" value=\\\"yes\\\" NAME=\\\"epost\\\">Yes, please!\";
echo  \"<input type=\\\"radio\\\" value=\\\"no\\\" NAME=\\\"epost\\\">No, thank you.\";
echo  \"<input type=hidden name=\\\"picture\\\" value=\\\"$picture\\\">\";
echo  \"<input type=hidden name=\\\"remail\\\" value=\\\"$remail\\\">\";
echo  \"<input type=hidden name=\\\"recipient\\\" value=\\\"\" . stripslashes(htmlentities($recipient)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"semail\\\" value=\\\"$semail\\\">\";
echo  \"<input type=hidden name=\\\"sender\\\" value=\\\"\" . stripslashes(htmlentities($sender)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"message\\\" value=\\\"\" . stripslashes(htmlentities($message)) .  \"\\\">\";
echo  \"<input type=\\\"submit\\\" value=\\\"Submit\\\"></form><br>\";

}

else  {

echo  \"<P><hr width=\\\"50%\\\"><P><strong>You have not YET sent the card.</strong><p>\\n\";
echo  \"<form method=\\\"GET\\\" action=\\\"send.php3\\\">\";
echo  \"<input type=\\\"radio\\\" value=\\\"yes\\\" NAME=\\\"epost\\\">Yes, please send my card!\";
echo  \"<input type=\\\"radio\\\" value=\\\"no\\\" NAME=\\\"epost\\\">No thank you.\";
echo  \"<input type=hidden name=\\\"picture\\\" value=\\\"$picture\\\">\";
echo  \"<input type=hidden name=\\\"remail\\\" value=\\\"$remail\\\">\";
echo  \"<input type=hidden name=\\\"recipient\\\" value=\\\"\" . stripslashes(htmlentities($recipient)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"semail\\\" value=\\\"$semail\\\">\";
echo  \"<input type=hidden name=\\\"sender\\\" value=\\\"\" . stripslashes(htmlentities($sender)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"message\\\" value=\\\"\" . stripslashes(htmlentities($message)) .  \"\\\">\";
echo  \"<input type=hidden name=\\\"idnumber\\\" value=\\\"$idnumber\\\">\";
echo  \"<input type=hidden name=\\\"\\\" value=\\\"$\\\">\";
echo  \"<input type=\\\"submit\\\" value=\\\"Submit\\\"></form><br>\";

}

}          // End of verification for $semail
else { echo  \"<strong>This card was NOT sent because a valid email address was not provided!</strong><p>\\n\"; }

}          // End of verification for $remail
else { echo  \"<strong>A preview was NOT provided because a valid email address was not provided!</strong><p>\\n\"; }

?>

</body>
</html>
Avatar billede partyguiden Nybegynder
24. september 2001 - 12:49 #6
Så er der bare fejl på linie 85
Avatar billede limemedia Nybegynder
24. september 2001 - 13:24 #7
er lidt svært når du ikke siger hvad fejlen er, men prøv at rette linie 85 til
echo  \"<P><hr width=\\\"50%\\\"><P>Your card number \".$idnumber.\" has been sent to \".stripslashes($recipient);
Avatar billede partyguiden Nybegynder
25. september 2001 - 08:05 #8
Fejlen er: Parse error: parse error in send.php3 on line 85
Avatar billede partyguiden Nybegynder
25. september 2001 - 08:06 #9
Hvad er reglerne for at tælle linier!
Avatar billede partyguiden Nybegynder
25. september 2001 - 08:25 #10
Skal man tælle hver linie eller ikke dem uden mellemrum.
Avatar billede partyguiden Nybegynder
25. september 2001 - 08:29 #11
Der er stadig væk samme fejl, du kan se siden på:http://pg.whitehat.dk/cards/send.phtml
Du skal udfylde send.phtml før du kommer til siden
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