Hello,
I'm done with my html and css file and now I'm trying to start with the php , but after I type
<?php
?>
and then try to type

$name = $_post['name'];

line 9 <?php
ine10 $name = $_post['name'];
line11 ?>

I get error "There is a syntax error on line 11 , code hinting may not work until you fix this error"
I don't know how to fix it .. it my first time useing php is the problem is from my html or is it from php and how can I fix this error

here is my html code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="CSS/main.css" type="text/css" /> 
</head>

<body>
<center> <div id="wrapper"> 
<h1> Website Feedback Form </h1>
<h5> Please complete the following form and click SEND MESSAGE. <br/> Thank you for your comments. </h5>
<div id="background"> 
<table align="center">
<form action="contact.php" method="post" name="contact"> 
<br/> 

 <tr>
        <td align="right" valign="top"> <label >Name: </label> </td> 
        <td> <input name="name" type="text" size="37" maxlength="30" />
<br/> </td> 
        </tr>


<tr> 
<td align="right" valign="top"> <label> Email Address:</label> </td>
<td> <input name="Email" type="text" size="37" maxlength="30" />
<br/> </td>   </tr>



<tr> 
<td align="right" valign="top"> <label> Subject: </label> </td>
<td> <input name="subject" type="text" size="37" maxlength="30" />
<br/> </td> </tr>


<tr>
<td align="right" valign="top"><label> Message: </label> </td>
<td> <textarea name="Message" cols="29" rows="15"></textarea>
<br/> </td> </tr>


<tr>
<td>&nbsp;</td>
   <td colspan="2" style="text-align:center">
    <input name="Clear All Fields" type="button" value="Clear All Fields" /> 
   <input name="Send Message" type="button" value="Send Message" style="float:right"/> </td> </tr>


</table>
</form>



</div>
<center> <img src="images/sendmail.jpg"/> </center>
</div>
</center>
</body>
</html>

and this is my php code I only typed php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
?>

</body>
</html>

Recommended Answers

All 2 Replies

assign id's to your form inputs.

<input type="text" name="name" id="name">

then when you submit the form, the php page will grab the id called name

<?php
$name = $_POST['name'];
echo $name;
?>

It looks like what you typed is correct. If you have a form with an <input> field that has the "name" attribute set to "name", then its content is stored in $_POST['name'] (capital letters in the $_POST part!), on the page that is loaded by submitting the form. So it will only be available on the page that is loaded when the form is submitted, not after that! If you want to keep using that data, you can consider storing it in session variables (here's the link to sessions on php.net: http://php.net/manual/en/session.examples.basic.php).

So, shortly summarized, you can access the data like this:

<form action="" method="post">
<input type="text" name="name"/>
<input type="submit"/>
</form>

<?php
// Echo the data the user has submitted. The form method was "post", so the data is stored in
// $_POST. If the method had been "get", the data had been stored in $_GET.
echo 'You have just submitted a form. The name you entered was: ' . $_POST['name'] . '.';

// Optionally store it in a variable that will only available on this page.
$name = $_POST['name'];

// Optionally store it in a session variable, so that it will also be available on other pages.
// If you want to use this, you should use the session_start() function in the first lines
// if your document.
$_SESSION['name'] = $_POST['name'];
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.