I downloaded a free php script for a new site I want to start. I changed the addlistings file to add more choices for people to choose from when submitting information. I changed the add file (with the insert data etc) and didn't change anything except add what I was changing.
I uploaded it into my hosting company and tested it. After I fill out the form and click submit it says it was posted successfully. I get no error messages. But no data actually gets inserted into my database table.
What could be wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's hard to say what might be wrong based on the information you have "not" provided. Your best bet is to add some debug information to the process.php script to determine what the error is but this requires some programming knowledge. The other thing you could do is to open the SQL db using something like phpAdmin and look at the db itself. Look to see if the db exists. Look to see if the data fields and data are actually entered, etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if (!$rtype || !$rent || !$deposit || !$community || !$phone || !$desc) {
echo "Error!! You have not entered the following field(s).Hit back and try again<br>\n";
$fields_to_validate = array('rtype', 'rent', 'deposit', 'community', 'phone', 'desc');
// validate above fields.
$field_display_value = array('Property Type', 'Rent', 'Deposit', 'Community', 'Telephone', 'Description');
// if the field is not set then show the above display value.
echo "<ul>\n";
for($a = 0;$a < count($fields_to_validate);$a++) {
// loop through fields and check whether that has been set or not.
if (!${$fields_to_validate[$a]}) {
CREATE TABLE `listings` (
`rid` int(15) NOT NULL auto_increment,
`llid` int(6) NOT NULL default '0',
`contact` varchar(50) NOT NULL default '',
`phone` varchar(10) NOT NULL default '',
`davail` varchar(50) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`web` varchar(200) NOT NULL default '',
`rtype` varchar(50) NOT NULL default '',
`community` varchar(100) NOT NULL default '',
`add` varchar(100) NOT NULL default '',
`rent` varchar(10) NOT NULL default '',
`deposit` varchar(10) NOT NULL default '',
`lease` varchar(10) NOT NULL default '',
`size` varchar(10) NOT NULL default '',
`utilities` varchar(10) NOT NULL default '',
`bed` varchar(10) NOT NULL default '',
`bath` varchar(10) NOT NULL default '',
`pets` varchar(10) NOT NULL default '',
`smkg` varchar(10) NOT NULL default '',
`furnished` varchar(4) NOT NULL default '',
`fs` varchar(10) NOT NULL default '',
`wd` varchar(10) NOT NULL default '',
`dish` varchar(10) NOT NULL default '',
`air` varchar(10) NOT NULL default '',
`garage` varchar(10) NOT NULL default '',
`deck` varchar(10) NOT NULL default '',
`plgrnd` varchar(10) NOT NULL default '',
`school` varchar(10) NOT NULL default '',
`bus` varchar(10) NOT NULL default '',
`pkg` varchar(10) NOT NULL default '',
`sauna` varchar(10) NOT NULL default '',
`pool` varchar(10) NOT NULL default '',
`cable` varchar(10) NOT NULL default '',
`internet` varchar(10) NOT NULL default '',
`desc` text NOT NULL,
`ldate` date NOT NULL default '0000-00-00',
`img1` varchar(25) NOT NULL default '',
`img2` varchar(25) NOT NULL default '',
PRIMARY KEY (`rid`,`community`,`bed`,`bath`,`smkg`,`pets`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
So when I go to the page and enter the information on the form and press submit it say's it listed successfully but when I go into phpAdmin and try to browse the table, there is no contents in the table.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's hard to say what might be wrong. The best bet is to add some debug code to your process.php file to see where things go wrong.
If you really need more help you will have to send me a link to your form.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I downloaded a free php script for a new site I want to start. I changed the addlistings file to add more choices for people to choose from when submitting information. I changed the add file (with the insert data etc) and didn't change anything except add what I was changing.
I uploaded it into my hosting company and tested it. After I fill out the form and click submit it says it was posted successfully. I get no error messages. But no data actually gets inserted into my database table.
What could be wrong?
It's hard to say what might be wrong based on the information you have "not" provided. Your best bet is to add some debug information to the process.php script to determine what the error is but this requires some programming knowledge. The other thing you could do is to open the SQL db using something like phpAdmin and look at the db itself. Look to see if the db exists. Look to see if the data fields and data are actually entered, etc.
here is my proccess.php script. I've checked my phpAdmin and the table is created (I've attached it also for review.
<?php include ("".$_SERVER['DOCUMENT_ROOT']."/includes/accesscontrol.php");
include ("".$_SERVER['DOCUMENT_ROOT']."/includes/config.php");
$contact = addslashes(strip_tags($_POST['contact']));
$phone = addslashes(strip_tags($_POST['phone']));
$davail = addslashes(strip_tags($_POST['davail']));
$email = addslashes(strip_tags($_POST['email']));
$web = addslashes(strip_tags($_POST['web']));
$rtype = addslashes(strip_tags($_POST['rtype']));
$community = addslashes(strip_tags($_POST['community']));
$add = addslashes(strip_tags($_POST['add']));
$rent = addslashes(strip_tags($_POST['rent']));
$deposit = addslashes(strip_tags($_POST['deposit']));
$lease = addslashes(strip_tags($_POST['lease']));
$size = addslashes(strip_tags($_POST['size']));
$utilities = addslashes(strip_tags($_POST['utilities']));
$bed = addslashes(strip_tags($_POST['bed']));
$bath = addslashes(strip_tags($_POST['bath']));
$pets = addslashes(strip_tags($_POST['pets']));
$smkg = addslashes(strip_tags($_POST['smkg']));
$furnished = addslashes(strip_tags($_POST['furnished']));
$fs = addslashes(strip_tags($_POST['fs']));
$wd = addslashes(strip_tags($_POST['wd']));
$dish = addslashes(strip_tags($_POST['dish']));
$air = addslashes(strip_tags($_POST['air']));
$garage = addslashes(strip_tags($_POST['garage']));
$deck = addslashes(strip_tags($_POST['deck']));
$plgrnd = addslashes(strip_tags($_POST['plgrnd']));
$school = addslashes(strip_tags($_POST['school']));
$bus = addslashes(strip_tags($_POST['bus']));
$pkg = addslashes(strip_tags($_POST['pkg']));
$sauna = addslashes(strip_tags($_POST['sauna']));
$pool = addslashes(strip_tags($_POST['pool']));
$cable = addslashes(strip_tags($_POST['cable']));
$internet = addslashes(strip_tags($_POST['internet']));
$desc = addslashes(strip_tags($_POST['desc']));
$imgone=$HTTP_POST_FILES['img1']['name'];
$imgtwo=$HTTP_POST_FILES['img2']['name'];
if (!$rtype || !$rent || !$deposit || !$community || !$phone || !$desc) {
echo "Error!! You have not entered the following field(s).Hit back and try again<br>\n";
$fields_to_validate = array('rtype', 'rent', 'deposit', 'community', 'phone', 'desc');
// validate above fields.
$field_display_value = array('Property Type', 'Rent', 'Deposit', 'Community', 'Telephone', 'Description');
// if the field is not set then show the above display value.
echo "<ul>\n";
for($a = 0;$a < count($fields_to_validate);$a++) {
// loop through fields and check whether that has been set or not.
if (!${$fields_to_validate[$a]}) {
echo "<li><font color=\"#FF0000\">$field_display_value[$a]</font>\n";
}
}
echo "</ul>\n";
} else {
$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;
$date = date("Ymd");
$day = substr($date,6,2);
$month = substr($date,4,2);
$year = substr($date,0,4);
$tdate="$year-$month-$day";
$rst=mysql_query("SELECT * FROM users WHERE email='$uid' and passwd='$pwd' ");
if ($row = mysql_fetch_array($rst))
{
$llid=$row["llid"];
// db insert and redirection
mysql_query ("INSERT INTO listings (llid, contact, phone, davail, email, web, rtype, community, add, rent, deposit, lease, size, utilities, bed, bath, pets, smkg, furnished, fs, wd, dish, air, garage, deck, plgrnd, school, bus, pkg, sauna, pool, cable, internet, ldate, img1, img2) VALUES ('$llid', '$contact', '$phone', '$davail', '$email', '$web', '$rtype', '$community', '$add', '$rent', '$deposit', '$lease', '$size', '$utilities', '$bed', '$bath', '$pets', '$smkg', '$furnished', '$fs', '$wd', '$dish', '$air', '$garage', '$deck', '$plgrnd', '$school', '$bus', '$pkg', '$sauna', '$pool', '$cable', '$internet', '$tdate', '$img1', '$img2')");
if (is_uploaded_file($HTTP_POST_FILES['img1']['tmp_name'])) {
if ($HTTP_POST_FILES['img1']['size']>$max_size) { echo "The file is too big<br>\n"; exit; }
$res = move_uploaded_file($HTTP_POST_FILES['img1']['tmp_name'], $abpath .
$HTTP_POST_FILES['img1']['name']);
chmod("$abpath".$HTTP_POST_FILES['img1']['name']."", 0777);
if (!$res) { echo "upload failed!<br>\n"; exit; } else { echo "upload successful<br>\n"; }
$img1=$HTTP_POST_FILES['img1']['name'];
}
if (is_uploaded_file($HTTP_POST_FILES['img2']['tmp_name'])) {
if ($HTTP_POST_FILES['img2']['size']>$max_size) { echo "The file is too big<br>\n"; exit; }
$res = move_uploaded_file($HTTP_POST_FILES['img2']['tmp_name'], $abpath .
$HTTP_POST_FILES['img2']['name']);
chmod("$abpath".$HTTP_POST_FILES['img2']['name']."", 0777);
if (!$res) { echo "upload failed!<br>\n"; exit; } else { echo "upload successful<br>\n"; }
$img2=$HTTP_POST_FILES['img2']['name'];
}}
echo "Listing successfully added <a href=\"index.php\">Landlord Index</a>";
}
?>
______________________________________________
CREATE TABLE `listings` (
`rid` int(15) NOT NULL auto_increment,
`llid` int(6) NOT NULL default '0',
`contact` varchar(50) NOT NULL default '',
`phone` varchar(10) NOT NULL default '',
`davail` varchar(50) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`web` varchar(200) NOT NULL default '',
`rtype` varchar(50) NOT NULL default '',
`community` varchar(100) NOT NULL default '',
`add` varchar(100) NOT NULL default '',
`rent` varchar(10) NOT NULL default '',
`deposit` varchar(10) NOT NULL default '',
`lease` varchar(10) NOT NULL default '',
`size` varchar(10) NOT NULL default '',
`utilities` varchar(10) NOT NULL default '',
`bed` varchar(10) NOT NULL default '',
`bath` varchar(10) NOT NULL default '',
`pets` varchar(10) NOT NULL default '',
`smkg` varchar(10) NOT NULL default '',
`furnished` varchar(4) NOT NULL default '',
`fs` varchar(10) NOT NULL default '',
`wd` varchar(10) NOT NULL default '',
`dish` varchar(10) NOT NULL default '',
`air` varchar(10) NOT NULL default '',
`garage` varchar(10) NOT NULL default '',
`deck` varchar(10) NOT NULL default '',
`plgrnd` varchar(10) NOT NULL default '',
`school` varchar(10) NOT NULL default '',
`bus` varchar(10) NOT NULL default '',
`pkg` varchar(10) NOT NULL default '',
`sauna` varchar(10) NOT NULL default '',
`pool` varchar(10) NOT NULL default '',
`cable` varchar(10) NOT NULL default '',
`internet` varchar(10) NOT NULL default '',
`desc` text NOT NULL,
`ldate` date NOT NULL default '0000-00-00',
`img1` varchar(25) NOT NULL default '',
`img2` varchar(25) NOT NULL default '',
PRIMARY KEY (`rid`,`community`,`bed`,`bath`,`smkg`,`pets`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
So when I go to the page and enter the information on the form and press submit it say's it listed successfully but when I go into phpAdmin and try to browse the table, there is no contents in the table.
It's hard to say what might be wrong. The best bet is to add some debug code to your process.php file to see where things go wrong.
If you really need more help you will have to send me a link to your form.