Uploading data to Mysql database using html form trouble

I cannot spot a mistake in here, maybe you can???

html form…

[code]

        	<input type="text" name="title" placeholder="Posting Title" /><br>
			
            <input type="datetime" name="_when" placeholder="Time of Sale" /><br>
            
            <input type="text" name="location" placeholder="Location of Sale" /><br>
            
            <input type="text" name="mainitems" placeholder="Main Items of Sale" /><br>

            <input type="submit" value="Post It!"/>
            
        </form>[/code]

connect.php…

[php]$title=$_POST[‘title’];
$location=$_POST[‘location’];
$_when=$_POST[’_when’];
$mainitems=$_POST[‘mainitems’];

mysql_connect($localhost,$username,$password);
mysql_select_db($database) or die( “Unable to select database”);

$sql = “INSERT INTO posting (title,location,_when,mainitems) VALUES
(’$title’,’$location’,’$_when’,’$mainitems’)”;[/php]

MySQL table…

Field 	          Type         Null	   Default
posting_id 	int(11)	        No 	 	 
title 	       varchar(50)	No 	 	 
location       varchar(100)	No 	 	 
_when 	      varchar(25)	No 	 	 
mainitems      varchar(150)	No 	 	

When I put quotes arounds these [php]posting (title,location,_when,mainitems)[/php] I get the error message

I removed enctype=“text/plain”

from

<form action="connect.php" method="post">

and it worked

Still not working for me. At a loss might just start over

not working? getting errors or is inserting blank fields?

inserting blank fields

change:

<form action="connect.php" method="post">

to:

<form action="connect.php" method="GET">

and
[php]
$title = $_POST[‘title’];
$location=$_POST[‘location’];
$_when=$_POST[’_when’];
$mainitems=$_POST[‘mainitems’];
[/php]

to:
[php]
$title = $_GET[‘title’];
$location=$_GET[‘location’];
$_when=$_GET[’_when’];
$mainitems=$_GET[‘mainitems’];
[/php]

use GET Method instead.

using the GET method worked perfectly… WTF?

And now I switched it back to POST and it also worked…I don’t know what is going on here

yeah is very weird because on my localhost it always worked

but keep using GET instead you are not sending out any sensitive information so get is fine

I heard that POST is a lil Buggy sometimes.

I suppose it is…Thanks a lot for your help and not giving up on me. Very much appreciated

you are very welcome.

GET isn’t good for everything. It’s ok for small things which get redirected quickly, but say you make a forum or blog and you insert a whole post, you can’t use GET.

True

Very good to know but for this purpose it shall do just fine

Sponsor our Newsletter | Privacy Policy | Terms of Service