Log in

View Full Version : Resolved Please help corect my php code



xaverius
10-13-2011, 05:29 PM
the issue is resolved

traq
10-13-2011, 07:43 PM
use the forum [.php.] tags to make your code more readable.

the variable names you use in your email template do not match the names you assign to the form values:
$emailField = $_POST['email'];
$bankField = $_POST['bank'];
$rekeningField = $_POST['rekening'];
$namaField = $_POST['nama'];
$gameField = $_POST['game'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Lokasi: $bank <br>
Rekening: $rekening <br>
Nama: $nama<br>
Game: $game <br>
EOD;for example, $_POST['bank'] is assigned to $bankField, but later, you try to use $bank.

in addition, you need to sanitize user input before sending it to your email. Since your email is being sent with a text/html mime type, a malicious user could send some javascript or an image tag inside their message, which could be executed when you read the email (depending on your email client settings). You should use something like strip_tags() on every form field before putting them in the email.

xaverius
10-13-2011, 08:03 PM
the issue is resolved

xaverius
10-13-2011, 08:05 PM
the issue is resolved

xaverius
10-13-2011, 08:20 PM
the issue is resolved

traq
10-14-2011, 01:24 AM
I have tried to equalize between the form and the variable, but my email is still not working.You haven't changed them. for example:


// name of variable holding form data: $bankField
$bankField = $_POST['bank'];
// name of variable used in email: $bank
Bank: $bank <br>
// this variable is empty (actually, it is not even set), so there is no info in you email.
// you must use the name you assigned to the value - random names will not work.
This problem exists with every variable you are using.

xaverius
10-14-2011, 09:39 AM
thanks for the explanation. The fault is I have to upload all my files first to hosting. Thanks for helping.

traq
10-14-2011, 03:13 PM
no problem. glad I could help

If your question has been answered, please mark your thread "resolved":
On your original post (post #1), click [edit], then click [go advanced]. In the "thread prefix" box, select "Resolved". Click [save changes].