Jump to content

SamohtVII

Members
  • Posts

    55
  • Joined

  • Last visited

Posts posted by SamohtVII

  1. I have a form posting 3 things, title, user, and content and it only ends up inserting the content and date parts into the table.insert.php:

    <?php$con=mysql_connect('localhost','root','*******');// Check connectionif (!$con)  {  echo "Failed to connect to MySQL: " . mysql_error();  }mysql_select_db("tutorials_blog2", $con);$sql="INSERT INTO posts (username, title, content, date)VALUES('$_POST[Username]','$_POST[Title]','$_POST[Content]', UNIX_TIMESTAMP())";if (!mysql_query($sql, $con))  {  die('Error: ' . mysql_error());  }echo "1 record added";mysql_close($con);?>

    This is the only place i can see anything being wrong but i'm not sure what's the problem. maybe my form?

    <form action="insert.php" method="post">Username: <input type="text" name"Username">Title: <input type="text" name"Title" size="30">Content: <input type="text" name="Content" class="inputtext"><input type="submit">

    Please help. ty

  2. Hi all,I have a php file called insert and a DB called tutorials_blog and a table called posts with a username, title and content fields. I want to make a form insert data into a table but it never inserts, doesn't give me any messages just opens up a blank page of insert.php. insert.php

    <?php$link = mysql_connect('localhost', 'root', '*******');if (!$link) {  die('Could not connect: ' .mysql_error());}mysql_selectdb("tutorials_blog");// Check connectionif (mysqli_connect_errno())  {  echo "Failed to connect to MySQL: " . mysqli_connect_error();  }$link="INSERT INTO posts (username, title, content)VALUES('$username','$title','$content')";$result = mysql_query($link);  //order executesif($result){echo("<br>Input data is succeed");} else{echo("<br>Input data is fail");}mysqli_close($con);?>

    blog.php

    	 <form action="insert.php" method="post">	    Username: <input type="text" name"username">	    Title: <input type="text" name"title">	    Content: <input type="text" name="content">	    <input type="submit">

×
×
  • Create New...