
Originally Posted by
nadeem14375
Dear Please help me, I am wondering for many weeks to solve this problem, but could not.
That is because you are using GET as your Ajax Submission, not POST. So if you change $_POST to $_GET, it will work. However, you should really adjust this further, as you have opened a SQL Injection.
You should instead change your code to as follows:
PHP Code:
session_start();
include("conn.php");
$today = date("Y-m-d");
$sql_ad_no = mysql_query("select max(ad_no) from ad_info") or die(mysql_error());
$info_ad_no = mysql_fetch_row( $sql_ad_no );
$ad_no = $info_ad_no[0];
$ad_no = $ad_no+1;
$city = mysql_real_escape_string($_GET['city']);
$country = mysql_real_escape_string($_GET['country']);
$category = mysql_real_escape_string($_GET['category']);
$sub_category_no = mysql_real_escape_string($_GET['sub_category_no']);
$title = mysql_real_escape_string($_GET['title']);
$price = mysql_real_escape_string($_GET['price']);
$description = mysql_real_escape_string($_GET['description']);
$email = mysql_real_escape_string($_GET['email']);
$website = mysql_real_escape_string($_GET['website']);
$user_type = mysql_real_escape_string($_GET['user_type']);
$phone_no = mysql_real_escape_string($_GET['phone_no']);
$address = mysql_real_escape_string($_GET['address']);
$result = mysql_query("INSERT INTO ad_info (
ad_no,
ad_date,
city,
country,
CATEGORY_NO,
sub_category_no,
title,
price,
description,
email,
website,
user_type,
phone_no,
address
) VALUES (
$ad_no,
'$today',
'$city',
'$country',
'$category',
'$sub_category_no',
'$title',
'$price',
'$description',
'$email',
'$website',
'$user_type',
'$phone_no',
'$address'
)");
Bookmarks