1

I have just set up a new Apache2 server which is still in development (theflyingrat.com) and because I am a YouTuber, I have a form where people can submit their video ideas to me, except after I fill out the form and submit it, Chrome gives me a 500 error.

This is the html form...

<form action="submit-a-video.php" method="post">
First name:<br>
<div class="right">
    If you want to help me make videos, please submit an idea here<br>
    I like to entertain you guys but I just have trouble finding ideas!<br>
    Although, please keep in mind that I am only a student and as I get older,<br>
    I will struggle for time... (Homework of course!)<br>
    Thanks for understanding!<br>
    -Joey.
</div>
<input type="text" name="firstname" value="" style="height:20px; width: 40%; border-radius:5px;" required>
<br>
Last name:<br>
<input type="text" name="lastname" value="" style="height:20px; width: 40%; border-radius:5px;" required>
<br>E-mail:<br>
<input type="email" name="email" value="" style="height:20px; width: 40%; border-radius:5px;" required>
<br>Your request:<br>
<textarea name="message" required style="width:40%; height:160px; border-radius:5px"></textarea>
<br>
<button type="submit" class="loginbtnsml">Submit</button>
</form>

This is the php processor...

<?php

$file = fopen('requests/requests.txt', 'w');

fwrite($file, "Hey Rat\n" . $_POST["firstname"] . " " . $_POST["lastname"] . " has a video request!\nThe request is:\n\n\" . $_POST["message"] . "\n\nTo ask for more information, please email:" $_POST["email"];
fclose($file);

header("Location: thanks.html");
?>

Thanks in advance for you help, and sorry for your time, Rat

Joey M
  • 187
  • 1
  • 14
  • as the colour coding above shows, you have some basic syntax errors there –  Apr 10 '19 at 02:55
  • @tim Well maybe, but it was working fine earlier... – Joey M Apr 10 '19 at 03:04
  • "PHP Parse error: syntax error, unexpected '"', expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/d8mJnT/prog.php on line 5" if your not seeing errors, you really need to turn them on –  Apr 10 '19 at 03:15
  • Ah thanks @tim, yeah errors weren't on. Sorry about that! – Joey M Apr 10 '19 at 03:52

2 Answers2

0

ANSWER

"PHP Parse error: syntax error, unexpected '"', expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/d8mJnT/prog.php on line 5"

From Tim in the comment above. It also turns out, apache2 (by default) turns off errors in php for some reason.

Joey M
  • 187
  • 1
  • 14
0

@Rat

Your code has syntax error:

Try this:

<?php

$file = fopen('requests/requests.txt', 'w');

fwrite($file, "Hey Rat\n" . $_POST["firstname"] . " " . $_POST["lastname"] . " has a video request!\nThe request is:\n\n" . $_POST["message"] . "\n\nTo ask for more information, please email:" . $_POST["email"]);

fclose($file);

header("Location: thanks.html");
?>
Vasant Hun
  • 61
  • 4