Previously, the PHP codebase I was using was that written by others, and I used their code to tinker with so I could get an understanding how PHP works.
Now that I am comfortable using PHP, I have written my own short PHP script from scratch with the aim of it seeing my newsletter system functioning at minimal, for the first time.
The newsletters system is made with HTML/PHP/MySQL.
I am having a problem with the PHP side of things where I am getting an error:
... which is:
I am hoping someone that knows allot about PHP could take a look at my code and see whats wrong with it?
PHP code within confirm.html:
HTML FORM code within index.html:
Now that I am comfortable using PHP, I have written my own short PHP script from scratch with the aim of it seeing my newsletter system functioning at minimal, for the first time.
The newsletters system is made with HTML/PHP/MySQL.
I am having a problem with the PHP side of things where I am getting an error:
PHP Parse error: syntax error, unexpected T_IF on line 50
Code:
if $_POST['action'] == 'Register' {
PHP code within confirm.html:
Code:
<?php $link = mysql_connect('localhost', 'testusr', 'testpw'); mysql_select_db('testdb', $link); $email = $_POST['e-mail']; $query = if $_POST['action'] == 'Register' { if $_POST['newsletter'] == 'Mens' { "INSERT INTO newsletters(mens) VALUES('$email')"; } elseif $_POST['newsletter'] == 'Mens & Womens' { "INSERT INTO newsletters(mensandwomens) VALUES('$email')"; } elseif $_POST['newsletter'] == 'Womens' { "INSERT INTO newsletters(womens) VALUES('$email')"; } ;} mysql_query ($link, $query); mysql_close($link); ?>
Code:
<FORM action="confirm.html" method="post"> <DIV> <SPAN class="input"> Action: <SELECT name="action"> <OPTION>Register</OPTION> <OPTION>Unregister</OPTION> </SELECT>    E-mail: <INPUT name="e-mail" type="text"></INPUT>    Newsletter: <SELECT name="newsletter"> <OPTION>Mens</OPTION> <OPTION>Mens & Womans</OPTION> <OPTION>Womens</OPTION> </SELECT>    <INPUT class="submit" type="submit" value="Submit"> </SPAN> </DIV> </FORM>
Comment