PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<html>
<hr>
<?php
if (isset($_POST['post']))
{
$title = $_POST['title'];
$body = $_POST['body'];
if($title&&$body)
{
$connect= mysql_connect ("localhost","root","951623") or die ("error");
mysql_select_db ("phplogin") or die("table not found");
$date = date("Y-m-d");
$insert = mysql_query(" INSERT INTO news VALUES ('','$title','$body','$date')");
}
else
{
echo " Va rog umpleti toate casutele";
}
}
?>
<form action='post.php'method='POST'>
Titlul:<br>
<input type="text" name='title'><p>
Tutorial:<br>
<textarea rows='6' cols='70' name='body'></textarea><p>
<input type="submit" name="post" value="Post">
</form>
<hr>
</html>
The problem is that the post action will not even appear on the site, i log on my site and no thing happens, no post action there, can someone tell me is there something wrong with my code?
What do you mean by "The post action will not even appear"?
What is wrong with this has many levels, here is what I would change...
1. The page isn't valid HTML format (ie, no <body> tag
2. You have attributes wrapped with single quotes instead of double
3. You do no have a space between action="post" and method="post"
4. You have no protection against SQL injection
So anyhow, the more details you can give of what you are expecting (or prefer) vs. what you are actually getting, the more we can help.
i mean it wont show nothing, not eaven the submit button, not eaven the body textarea, nothing, it is like that form action does not exist
i did the body, and corrected the st space between action am method , still does not work
ZetCoby wrote:what do you mean by quotes instead of double ?
' instead of "
I copy/pasted the code from your OP and it displays fine in my browser. The form seems to work, also (died on sql authentication, for obvious reasons).
i found the problem, when i included the file post.php it was Post.php i see that linux is case sensitive, did not have this problem on windows, but still te me what u mean about quotes instead of double ?, i am new to php