Hello to all.
I'm facing some problems with PHP scripting and I found this site very useful so I hope you will solve my problems too..
First of all, I'm working on my own webpage for a while and I'm just a beginner on all this HTML coding and PHP scripting.
I've been using this tutorial posted on Youtube by Joseph Montanez [in 2 parts]
http://www.youtube.com/watch?v=VbHsEafkyjM
http://www.youtube.com/watch?v=qUgul1RgSGk
You don't have to watch the whole tutorial, thing thing is that there are 3 files.
The first one is for the contact form look and it's a HTML document.
<html>
<head>
<title>
Danieloncarevic fotografije - KONTAKT
</title>
</head>
<body>
<form action="step2.php" method="post">
Ime i Prezime<br/><input type="text" name="username" /><br/>
E-mail adresa<br/><input type="text" name="email" /><br/>
Vasa poruka<br><textarea row="7" cols="70" name="inquiry"></textarea><br/>
<input type="submit" value="Posalji poruku"/>
</form>
</body>
</html>
The second one is the action to send the message to my e-mail address and to redirect to the third file. This one is a PHP file.
<?php
$name = $_POST['username'];
$email = $_POST['email'];
$text = $_POST['inquiry'];
//To, Subject, Message, Header
mail('example@example.com', 'Poruka sa neta', $text, 'From: ' . $name . ' <' . $email . '>');
header('Location: step3.html');
?>
The third and the last one is the message that the message has been sent successfully and it's a HTML document.
<html>
<head>
<title>Danieloncarevic fotografije - KONTAKT</title>
</head>
<body>
Hvala, Vasa poruka je uspjesno poslata.
</body>
</html>
As you can see, I did the same thing, just changing the thing that I should change for my website but after doing all that I got this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/fellipe56/public_html/st ep2.php:1) in /home/fellipe56/public_html/step2.php on line 10
I spent a lot of time finding something to solve my problem and after a while I found some post that maybe I should add something to my PHP file. Something like this:
if (!headers_sent()) {
header('Location: step3.html');
} else {
echo '<script type="text/javascropt">
document.location.href ='step3.html';
</script>';
}
So.. now my second file should you something like this:
<?php
$name = $_POST['username'];
$email = $_POST['email'];
$text = $_POST['inquiry'];
//To, Subject, Message, Header
mail('example@example.com', 'Poruka sa neta', $text, 'From: ' . $name . ' <' . $email . '>');
header('Location: step3.html');
if (!headers_sent()) {
header('Location: step3.html');
} else {
echo '<script type="text/javascropt">
document.location.href ='step3.html';
</script>';
}
?>
With this modification I got some other error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/fellipe56/public_html/step2.php on line 16
I really need to fix this as soon as possible.
Thanks for your help,
Fidel