PHP Post/Edit forms not working!
10-06-2009, 03:52 PM
|
PHP Post/Edit forms not working!
|
Posts: 5
Name: Josh Harris
|
Hey everyone!
I am new here but hopefully will become a more involving member of the forum over time
I have a problem with a website I am currently working on with a team of others, it is a motor vehicle classifieds website so has a Post-Advert and Edit-Advert forms.
The Post-Advert form is working fine and adverts are being submitted to the website ok along with their images. The problem I have is that when people come to edit their adverts not all of the fields are in the edit-advert form, when I try to add the missing field it messes the website up completly giving 'Page Cannot be Displayed' errors.
I have included the 2 files below. Any help fixing this would be appreciated.
Thanks
post-form.php (all fields working fine)
PHP Code:
<script type="text/javascript"> function textCounter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else cntfield.value = maxlimit - field.value.length; } </script>
<?php $ok = cp_filter($_GET['ok']); if ($err != "") { echo "<div id=\"err\" class=\"err\"><div id='closelink'><a href=\"#\" onClick=\"document.getElementById('err').style.display = 'none';\">X</a></div>$err</div>"; }
if ($ok == "ok") { echo "<div class=\"ok\"><strong>" . __('Thank you! Your classified ad has been submitted succesfully.','cp') . "</strong><br />"; if ( get_option("post_status") == "draft" && get_option('activate_paypal') != "yes") { echo __('Someone will review your ad shortly. If you have any questions, please contact the site owner.','cp') . "<br />"; } if ( get_option('activate_paypal') == "yes" ) { $post_id = (int)$_GET['id']; $post_title = $_GET['title']; $post_title = str_replace("+", " ", $post_title); $ad_value = get_option('ad_value'); // 10 $featured_ad_check = (int)$_GET['fid']; $lprice = (int)$_GET['lprice']; if ($featured_ad_check == '1') {$isfeatured = get_option('cp_featured_ad');} if ( get_option('cp_price_scheme') == "category" ) { $getcatid = $_GET['catid']; // 21 // if cat is blank then assign it the first category if ($getcatid == "") { $getcatid = "1"; } $cat_price = get_option('cp_cat_price_'.$getcatid); // 0 // if cat price is blank then assign it default price if ($cat_price != "") { $totalcost = $cat_price; } else { $totalcost = $ad_value; } } elseif( get_option('cp_price_scheme') == "percentage" ) { // first grab the % and then put it into a workable number $ad_percentage = (get_option('cp_ad_percent') * 0.01); // calculate the ad cost. Ad listing price x percentage. $totalcost = (trim($lprice) * trim($ad_percentage)); } else { $totalcost = $ad_value; } // calculate the total cost for the ad. $totalcost_out = $totalcost + $isfeatured; // put the total cost of the ad into a custom field add_post_meta($post_id, 'cp_totalcost', $totalcost_out, true); ?> <br />
<?php if ($totalcost_out != "0") { ?>
<?php _e('Please click the PayPal button below to submit your','cp'); ?> <b><?php echo get_option('currency'); ?><?php echo $totalcost_out; ?> <?php echo get_option('paypal_currency'); ?></b> <?php _e('listing fee.','cp'); ?><br /><?php _e('Your ad will not be published until payment has been received.','cp'); ?><br /><br /> <center>
<?php if(get_option('paypal_sandbox') == 1){ $paypalurl="https://www.sandbox.paypal.com/cgi-bin/webscr"; }else { $paypalurl="https://www.paypal.com/cgi-bin/webscr"; } ?>
<form target="_blank" action="<?php echo $paypalurl ?>" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="<?php echo get_option('paypal_email'); ?>"> <input type="hidden" name="item_name" value="<?php _e('Classified ad listing on ','cp') ?><?php bloginfo('name'); ?> <?php _e('for','cp') ?> <?php echo get_option("prun_period"); ?> <?php _e('days','cp'); ?>"> <input type="hidden" name="item_number" value="<?php echo $post_id; ?>"> <input type="hidden" name="amount" value="<?php echo $totalcost_out; ?>"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="notify_url" value="<?php echo get_option('home'); ?>/"> <input type="hidden" name="cancel_return" value="<?php echo get_option('home'); ?>/"> <input type="hidden" name="return" value="<?php echo get_option('home'); ?>/?payment=1"> <input type="hidden" name="currency_code" value="<?php echo get_option('paypal_currency'); ?>"> <input type="hidden" name="bn" value="IC_Sample"> <input type="image" src="<?php bloginfo('template_directory'); ?>/images/paypal_btn.gif" name="submit"> <img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form><br /> <span style="color: red; background-color: #fff; padding: 2px 5px;"><b><?php _e('IMPORTANT','cp');?></b></span> <?php _e('Be sure to click RETURN TO STORE (from paypal.com) for your ad to be activated.','cp'); ?> </center> <?php
} } echo "</div>"; } ?>
<div class="classform" id="formbox" <?php if ($err == "") { echo "style=\"display: none;\""; } ?>>
<div class='box-yellow'>
<h3 style="text-align:top;"><img src="<?php bloginfo('template_url'); ?>/images/star.png" border="0" alt="" />
<?php // if not charging for any ads if ( get_option('activate_paypal') != "yes" ) { _e('All ad listings are FREE.','cp'); }
// if paypal is turned on and NO category-level pricing elseif ( get_option('cp_price_scheme') == "single" && get_option('activate_paypal') == "yes" ) { ?> <?php _e('One ad listing costs','cp'); ?> <strong><?php echo get_option('currency'); ?><?php echo get_option('ad_value'); ?></strong> <?php _e('for','cp'); ?> <strong><?php echo get_option("prun_period"); ?> <?php _e('days.','cp'); ?></strong> <?php }
// if paypal is turned on and category-level pricing elseif ( get_option('cp_price_scheme') == "category" && get_option('activate_paypal') == "yes" ) { ?> <?php _e('Ad listing prices vary based on category. List your item for','cp'); ?> <strong><?php echo get_option("prun_period"); ?> <?php _e('days.','cp'); ?></strong> <?php } // if paypal is turned on and category-level pricing elseif ( get_option('cp_price_scheme') == "percentage" && get_option('activate_paypal') == "yes" ) {?> <?php _e('Ad listing price equates to','cp')?> <strong> <?php echo get_option('cp_ad_percent'); ?>%</strong> <?php _e('of your item price. List your item for','cp');?> <strong><?php echo get_option("prun_period"); ?> <?php _e('days.','cp'); ?></strong> <?php } ?>
</h3><br />
<?php if(get_option('ads_form_note') != "") { ?>
<?php echo stripslashes(get_option('ads_form_note')) ?> <?php } ?> </div>
<form action="" method="post" enctype="multipart/form-data" id="new_post2" name="new_post2"> <input type="hidden" name="action" value="post" /> <?php wp_nonce_field( 'new-post' ); ?>
<div class="left_form">
<label for="cat"><?php _e('Choose a Price Band','cp'); ?> <span>*</span></label> <?php if ( get_option('cp_price_scheme') == "category" && get_option('activate_paypal') == "yes" ) { ?> <?php cp_dropdown_categories_prices('show_option_none=Select One&orderby=name&order=ASC&hide_empty=0&hierarchical=1'); ?> <?php } else { ?> <?php wp_dropdown_categories('show_option_none=Select One&orderby=id&order=ASC&hide_empty=0&hierarchical=1'); ?> <?php } ?> <label for="title"><?php _e('Title','cp'); ?> <span>*</span></label> <input type="text" id="title" class="adfields" name="post_title" size="60" maxlength="100" value="<?php echo $_POST['post_title'];?>" /> <label for="price"><?php _e('Price','cp'); ?> <span>*</span> <small><?php _e('(do not enter currency symbol)','cp'); ?></small></label> <input type="text" id="price" class="adfields" name="price" size="60" maxlength="100" value="<?php echo $_POST['price']; ?>" /> <label for="location"><?php _e('Location','cp'); ?> <span>*</span></label> <input type="text" id="location" class="adfields" name="location" size="60" maxlength="100" value="<?php echo $_POST['location']; ?>" /> <label for="make"><?php _e('Make'); ?><span>*</span></label> <input type="text" id="make" class="adfields" name="make" size="60" maxlength="100" value="<?php echo $make; ?>" /> <label for="model"><?php _e('Model'); ?><span>*</span></label> <input type="text" id="model" class="adfields" name="model" size="60" maxlength="100" value="<?php echo $model; ?>" /> <label for="year"><?php _e('Model Year'); ?><span>*</span></label> <input type="text" id="year" class="adfields" name="year" size="60" maxlength="100" value="<?php echo $year; ?>" /> <label for="mileage"><?php _e('Mileage'); ?><span>*</span></label> <input type="text" id="mileage" class="adfields" name="mileage" size="60" maxlength="100" value="<?php echo $mileage; ?>" /> <label for="exterior"><?php _e('Exterior Colour'); ?><span>*</span></label> <input type="text" id="exterior" class="adfields" name="exterior" size="60" maxlength="100" value="<?php echo $exterior; ?>" /> <label for="interior"><?php _e('Interior Colour'); ?><span>*</span></label> <input type="text" id="interior" class="adfields" name="interior" size="60" maxlength="100" value="<?php echo $interior; ?>" /> <label for="doors"><?php _e('Number of Doors'); ?><span>*</span></label> <input type="text" id="doors" class="adfields" name="doors" size="60" maxlength="100" value="<?php echo $doors; ?>" /> </div>
<? // call this param so we can prefill the form for registered users global $current_user; ?>
<div class="right_form"> <label for="fuel">Fuel Type:<span>*</span></label> <select name='fuel' id='fuel' class='fuel' > <option value=''>Select One</option> <option> Petrol</option> <option> Diesel</option> </select> <label for="description"><?php _e('Vehicle Description','cp'); ?> <span>*</span></label> <textarea name="description" id="description" class="adfields" rows="10" cols="46" onkeydown="textCounter(document.new_post2.description,document.new_post2.remLen1,5000)" onkeyup="textCounter(document.new_post2.description,document.new_post2.remLen1,5000)"><?php echo $_POST['description']; ?></textarea><br />
<div class="limit"> <input disabled="disabled" readonly="readonly" type="text" name="remLen1" size="4" maxlength="4" value="5000" style="width: 40px;" /><span style="font-size:11px;"> <?php _e('characters left','cp'); ?></span> </div>
<label for="name_owner"><?php _e('Contact Name','cp'); ?> <span>*</span></label> <input type="text" id="name_owner" class="adfields" name="name_owner" size="60" maxlength="100" value="<?php if ($current_user->user_firstname != "") { echo $current_user->user_firstname ." ". $current_user->user_lastname; } else { echo $_POST['name_owner']; }?>" />
<label for="email"><?php _e('Contact Email','cp'); ?> <span>*</span> <small><?php _e('(will not be displayed)','cp'); ?></small></label> <input type="text" id="email" class="adfields" name="email" size="60" maxlength="100" value="<?php if ($current_user->user_email != "") { echo $current_user->user_email; } else { echo $_POST['email']; }?>" /> <label for="phone"><?php _e('Contact Phone','cp'); ?> </label> <input type="text" id="phone" class="adfields" name="phone" size="60" maxlength="100" value="<?php echo $_POST['phone']; ?>" /> <label for="post_tags"><?php _e('Tags','cp'); ?> <small><?php _e('(separate with commas)','cp'); ?></small></label> <input type="text" id="post_tags" class="adfields" name="post_tags" size="60" maxlength="100" value="<?php echo $_POST['post_tags']; ?>" />
<label for="post_tags"><?php _e('URL','cp'); ?> <small><?php _e('(i.e. http://www.mysite.com)','cp'); ?></small></label> <input type="text" id="cp_adURL" class="adfields" name="cp_adURL" size="60" maxlength="250" value="<?php echo $_POST['cp_adURL']; ?>" /> <label for="post_tags"><?php _e('Add images','cp'); ?> <small>(<?php _e('images must be under 1 MB','cp'); ?>)</small></label> <input type="file" name="images[]" class="wwIconified" /><br />
<br /> <?php if(get_option('cp_featured_ad') != "" && get_option('activate_paypal') == "yes" ) : ?> <div class="extrasbox"> <div style="margin:10px 10px 10px 0;"> <span class="alignleft" style="padding:10px;"><input name="featured_ad" value="1" type="checkbox" <?php if ($_POST['featured_ad'] == '1') { echo "CHECKED";} ?> /></span> <strong><?php _e('Featured Listing','cp'); ?> <?php echo get_option('currency'); ?><?php echo get_option('cp_featured_ad'); ?></strong><br /> <?php _e('Your listing will appear highlighted in yellow on the front page and category page.','cp'); ?> </div> </div> <?php endif; ?> </div> <div style="clear: both;"></div> <center> <div class="captcha"> <?php $nr1 = rand("0", "9"); $nr2 = rand("0", "9"); ?> <?php echo $nr1; ?> + <?php echo $nr2; ?> = <input type="text" name="total" style="width: 30px; text-align: center; border: 1px #DF0005 solid; padding: 4px;" maxlength="2" value="" /> <input type="hidden" name="nr1" value="892347<?php echo $nr1; ?>" /> <input type="hidden" name="nr2" value="234543<?php echo $nr2; ?>" /> </div> <input id="submit" type="submit" value="<?php _e('Submit Ad','cp'); ?>" class="postit" /> </center> </form> </div> <!-- // postbox --> <?php // } //if the form is ok don't display the form anymore ?>
tpl-edit-ad.php (form only displays some fields)
PHP Code:
<?php /* Template Name: Edit Ad Page */
$wpdb->hide_errors(); auth_redirect_login(); // if not logged in, redirect to login page nocache_headers();
global $userdata; get_currentuserinfo(); // grabs the user info and puts into vars
// check to see if the form has been posted. If so, validate the fields if(!empty($_POST['submit'])) { $title = trim($_POST['post_title']); $price = cp_filter($_POST['price']); $location = cp_filter($_POST['location']); $phone = cp_filter($_POST['phone']); $email = cp_filter($_POST['email']); $name_owner = cp_filter($_POST['name_owner']); $cp_adURL = cp_filter($_POST['cp_adURL']); $description = trim($_POST['description']); if($title == '') { $errmsg = __('Ad title cannot be blank','cp'); $hfield = '1'; } else if($price == '') { $errmsg = __('Price cannot be blank','cp'); $hfield = '2'; } else if($location == '') { $errmsg = __('Location cannot be blank','cp'); $hfield = '3'; } else if($email == '') { $errmsg = __('Email address cannot be blank','cp'); $hfield = '5'; } else if ( !cp_check_email($email) ) { $errmsg = __('Email address is not valid','cp'); $hfield = '5'; } else if($name_owner == '') { $errmsg = __('Name cannot be blank','cp'); $hfield = '6'; } else if($description == '') { $errmsg = __('The description cannot be blank','cp'); $hfield = '7'; }
// if there are no errors, then process the ad updates if($errmsg == '') { if ( get_option('filter_html') != "yes" ) { $description = cp_filter($description); }
// Put all post variables into an array $my_ad = array(); $my_ad['ID'] = trim($_POST['ad_id']); $my_ad['post_title'] = cp_filter($_POST['post_title']); $my_ad['post_content'] = $description;
//Add or edit images // First delete any images as posted $image_folder_name = "classipress"; $upload_arr = wp_upload_dir(); $imagedirectory = trailingsla****($upload_arr['basedir']) . $image_folder_name; $delimages=$_POST['delimages']; $noofdel=0; $notdel=0; $postedimages = explode(",", get_post_meta($my_ad['ID'], 'images', true)); $totalimages=count($postedimages); if (!empty($delimages)){ foreach ($delimages as $imagekey=> $delimage){ if ($delimage!=""){ $imagetodelete = $imagedirectory.'/'.basename($postedimages[$delimage]); $delstatus=unlink($imagetodelete); if($delstatus=="1"){ $noofdel++; // $listofdeleted=$delmessages.basename($postedimages[$delimage])." was deleted successfully.<br/>"; // can be used to see files being deleted array_splice($postedimages,$delimage,1); } else { $notdel++; // $listofnotdeleted=$delmessages.basename($postedimages[$delimage])." was not deleted<br/>"; // can be used to see files being deleted } } } $delmessages=$noofdel." images were deleted successfully<br/>".$listofdeleted; if($notdel!=0){ $delmessages.=$notdel."images were not deleted<br/>".$listofnotdeleted; } }
// Second Insert new images //1024 bytes = 1kb //1024000 bytes = 1mb // $image_folder_name = "classipress"; $size_bytes = 1024000; $size_mb = $size_bytes / 1024000; $limitedext = array(".gif",".png",".jpg",".jpeg");
// http://codex.wordpress.org/Function_Reference/wp_upload_dir // $upload_arr = wp_upload_dir();
// $dir_to_make = trailingsla****($upload_arr['basedir']) . $image_folder_name; // $dir_to_make = "wp-content/uploads/classipress"; $image_baseurl = trailingsla****($upload_arr['baseurl']) . $image_folder_name; $image_name = substr(sanitize_title(alphanumericAndSpace($title)), 0, 20); $i = rand(); $newimages = ""; $err2 = ""; while(list($key,$value) = each($_FILES['images']['name'])) { if(!empty($value)) { $filename = strtolower($value); $filename = str_replace(" ", "-", $filename); //get image extension $tipul = strrchr($filename,'.'); $filename = $image_name."-$i".$tipul; $add = "$imagedirectory/$filename"; $image = "$image_baseurl/$filename"; //$add = "$filename";
//Make sure that file size is correct $file_size = $_FILES['images']['size'][$key]; //getting the right size that coresponds with the image uploaded if ($file_size == "0"){ $err2 .= __('The file $value has 0 bytes.','cp') . "<br />"; } else { if ($file_size > $size_bytes){ $err2 .= __('The file $value is bigger than 2MB.','cp') . "<br />"; } } //check file extension $ext = strrchr($filename,'.'); if ( (!in_array(strtolower($ext),$limitedext)) ) { $err2 .= __('The file $value is not an image.','cp') . "<br />"; }
//echo $_FILES['images']['type'][$key]; if ( $err2 == "" ) { if (!file_exists($imagedirectory)) { mkdir($imagedirectory, 0777); } copy($_FILES['images']['tmp_name'][$key], $add); chmod("$add",0777);
//$images .= get_option('home')."/".$add.","; $newimages .= $image . ",";
} $err2 = ""; $i++; }//if empty $value }//end while
// Create new images array array_merge($postedimages); foreach ($postedimages as $image){ if ($image!=""){ $images=$images.$image.','; } }
// Update the ad in the db wp_update_post( $my_ad );
// now go back and update the meta fields update_post_meta($_POST['ad_id'], 'price', $price); update_post_meta($_POST['ad_id'], 'location', $location); update_post_meta($_POST['ad_id'], 'phone', $phone); update_post_meta($_POST['ad_id'], 'email', $email); update_post_meta($_POST['ad_id'], 'name', $name_owner); update_post_meta($_POST['ad_id'], 'cp_adURL', $cp_adURL); update_post_meta($_POST['ad_id'], 'images',$images.$newimages); $cp_dashboard_url = $_POST['dashboard_url']; $errmsg = '<div class="box-yellow"><b>' .$delmessages. __('Your ad has been updated!','cp') . '</b><br /><br /> <a href=".' . $cp_dashboard_url . '">' . __('My Dashboard ››','cp') . '</a></div>'; } else { $errmsg = '<div class="box-red"><strong>** ' . $errmsg . ' **</strong></div>'; $errcolor = 'style="background-color:#FFEBE8;border:1px solid #CC0000;"'; }
}
// get the ad id from the querystring. Need this for the sql statement $aid = $_GET["aid"];
$querystr = "SELECT wposts.* FROM $wpdb->posts wposts WHERE ID = $aid AND post_status <> 'draft' AND post_author = $userdata->ID";
// pull ad fields from db $getmyad = $wpdb->get_row($querystr, OBJECT);
// start main edit page require_once dirname( __FILE__ ) . '/form_process.php';
get_header(); include_classified_form(); ?>
<style type="text/css"> .mid2 { border:1px solid #CCC; margin-bottom:10px; padding:5px; } </style>
<script type="text/javascript"> function textCounter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else cntfield.value = maxlimit - field.value.length; } </script>
<div class="content"> <div class="main ins"> <div class="left"> <div class="product">
<?php if (get_option('cp_ad_edit') != "no") { ?> <?php if ($getmyad): ?>
<?php echo $err2.$errmsg; ?>
<form name="edit_ad" id="edit_ad" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="ad_id" value="<?php echo $getmyad->ID; ?>" /> <input type="hidden" name="dashboard_url" value="<?php echo cp_dashboard_url; ?>" />
<h2><?php _e('Edit Your Ad','cp');?></h2> <p><?$delmessages?><p> <p><?php _e('Edit the fields below and click save to update your ad. Your changes will be updated instantly on the site.','cp');?></p>
<p><strong><?php _e('Ad ID:','cp');?></strong> <span style="background-color:#eee;padding:5px;"><?php echo $getmyad->ID; ?></span></p>
<p><label><b><?php _e('Title','cp');?></b> *<br /> <input <?php if ($hfield == '1') { echo $errcolor; } ?> type="text" name="post_title" class="mid2" id="post_title" value="<?php echo $getmyad->post_title; ?>" size="50" maxlength="100" /></label></p>
<p><label><b><?php _e('Price','cp');?></b> *<br /> <input <?php if ($hfield == '2') { echo $errcolor; } ?> type="text" name="price" class="mid2" id="price" value="<?php echo get_post_meta($getmyad->ID, "price", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('Location','cp');?></b> *<br /> <input <?php if ($hfield == '3') { echo $errcolor; } ?> type="text" name="location" class="mid2" id="location" value="<?php echo get_post_meta($getmyad->ID, "location", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('Name','cp');?></b> *<br /> <input <?php if ($hfield == '6') { echo $errcolor; } ?> type="text" name="name_owner" class="mid2" id="name_owner" value="<?php echo get_post_meta($getmyad->ID, "name", true); ?>" size="50" maxlength="100" /></label></p>
<p><label><b><?php _e('Email','cp');?></b> *<br /> <input <?php if ($hfield == '5') { echo $errcolor; } ?> type="text" name="email" class="mid2" id="email" value="<?php echo get_post_meta($getmyad->ID, "email", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('Phone','cp');?></b><br /> <input type="text" name="phone" class="mid2" id="phone" value="<?php echo get_post_meta($getmyad->ID, "phone", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('URL','cp');?></b><br /> <input type="text" name="cp_adURL" class="mid2" id="cp_adURL" value="<?php echo get_post_meta($getmyad->ID, "cp_adURL", true); ?>" size="50" maxlength="250" /></label></p>
<p><b><?php _e('Description','cp');?></b> *<br /> <textarea <?php if ($hfield == '7') { echo $errcolor; } ?> name="description" class="mid2" id="description" rows="15" cols="57" onkeydown="textCounter(document.edit_ad.description,document.edit_ad.remLen1,5000)" onkeyup="textCounter(document.edit_ad.description,document.edit_ad.remLen1,5000)"><?php echo stripslashes($getmyad->post_content); ?></textarea></p>
<div class="limit"> <input readonly="readonly" type="text" name="remLen1" size="4" maxlength="4" value="5000" style="width: 50px;" /><span style="font-size:11px;"> <?php _e('characters left','cp'); ?></span> </div>
<p><b><?php _e('Images to be deleted','cp');?><small>(<?php _e('check images to be deleted','cp'); ?>)</small></b><br /> <? $matches = explode(",", get_post_meta($getmyad->ID, 'images', true)); foreach($matches as $key=>$var) { if ($var != "") { $thumb_var = str_replace(get_option('home')."/wp-content/uploads/classipress/", "", $var); $single_thumb_img_url = get_bloginfo('template_url')."/includes/img_resize.php?width=100&height=100&url=".$thumb_var; echo "<input type=\"checkbox\" name=\"delimages[]\" value=\"$key\"><img src=\"$single_thumb_img_url\"/>"; //echo "<a href=\"$var\" rel=\"group\"><img src=\"$single_thumb_img_url\" class=\"size-thumbnail\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" /></a>"."\n"; } else { if ( $matches[0] == "") { _e('There are no images','cp'); } } }
?>
<p><b><?php _e('Add images','cp'); ?> <small>(<?php _e('images must be under 1 MB','cp'); ?>)</small></b> <input type="file" name="images[]" class="wwIconified" value="<?php echo $_POST['images']; ?>"/><br /><p>
<p class="submit"><input type="submit" class="lbutton" value="<?php _e('Update Ad »','cp') ?>" name="submit" /></p> </form>
<?php else : ?>
<h2 class="center"><?php _e('Ad Not Found','cp');?></h2> <p class="center"><?php _e('Sorry, but you are looking for something that isn\'t here.','cp');?><br /> <?php _e('Go to','cp');?> <a href="<?php bloginfo('url')?><?php echo cp_dashboard_url; ?>"><?php _e('My Dashboard','cp');?> ››</a></p>
<?php endif; ?>
<?php } else { ?>
<h2 class="center"><?php _e('Ad Editing is Disabled','cp');?></h2> <p class="center"><?php _e('Your site administrator has disabled ad editing. Please contact them for further instructions.','cp');?><br /> <?php _e('Go to','cp');?> <a href="<?php bloginfo('url')?><?php echo cp_dashboard_url; ?>"><?php _e('My Dashboard','cp');?> ››</a></p>
<?php } ?>
</div> </div> <div class="right"> <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Page Sidebar')) : else : ?>
<?php endif; ?> </div> <div class="clear"></div> </div> </div>
<?php get_footer(); ?>
|
|
|
|
10-06-2009, 07:36 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 9,669
Name: Steven Bradley
Location: Boulder, Colorado
|
Which fields aren't displaying in the edit form?
|
|
|
|
10-06-2009, 08:16 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 5
Name: Josh Harris
|
Quote:
Originally Posted by vangogh
Which fields aren't displaying in the edit form?
|
The fields which arnt displaying are:
Make
Model
Year
Mileage
Exterior
Interior
Doors
Fuel
|
|
|
|
10-08-2009, 08:23 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 9,669
Name: Steven Bradley
Location: Boulder, Colorado
|
Not really anything to fix then. The form is working. It's just that none of those fields have been coded into the edit form. You'll have to add them to the edit form.
Look at one of the fields that's in both the post form and the edit form and use it as a model for adding the fields you want to add in the edit form.
|
|
|
|
10-13-2009, 07:23 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 5
Name: Josh Harris
|
I've edited the edit form to add the fields, it now redirects to a page not found page when the edit form is submitted... updated code below
PHP Code:
<?php /* Template Name: Edit Ad Page */
$wpdb->hide_errors(); auth_redirect_login(); // if not logged in, redirect to login page nocache_headers();
global $userdata; get_currentuserinfo(); // grabs the user info and puts into vars
// check to see if the form has been posted. If so, validate the fields if(!empty($_POST['submit'])) { $title = trim($_POST['post_title']); $price = cp_filter($_POST['price']); $location = cp_filter($_POST['location']); $make = cp_filter($_POST['make']); $model = cp_filter($_POST['model']); $year = cp_filter($_POST['year']); $mileage = cp_filter($_POST['mileage']); $exterior = cp_filter($_POST['exterior']); $interior = cp_filter($_POST['interior']); $doors = cp_filter($_POST['doors']); $email = cp_filter($_POST['email']); $name_owner = cp_filter($_POST['name_owner']); $description = trim($_POST['description']); if($title == '') { $errmsg = __('Ad title cannot be blank','cp'); $hfield = '1'; } else if($price == '') { $errmsg = __('Price cannot be blank','cp'); $hfield = '2'; } else if($location == '') { $errmsg = __('Location cannot be blank','cp'); $hfield = '3'; } else if($make == '') { $errmsg = __('Make cannot be blank','cp'); $hfield = '4'; } else if($model == '') { $errmsg = __('Model cannot be blank','cp'); $hfield = '5'; } else if($year == '') { $errmsg = __('Year cannot be blank','cp'); $hfield = '6'; } else if($mileage == '') { $errmsg = __('Mileage cannot be blank','cp'); $hfield = '7'; } else if($exterior == '') { $errmsg = __('Exterior cannot be blank','cp'); $hfield = '8'; } else if($interior == '') { $errmsg = __('Interior cannot be blank','cp'); $hfield = '9'; } else if($doors == '') { $errmsg = __('Doors cannot be blank','cp'); $hfield = '10'; } else if($email == '') { $errmsg = __('Email address cannot be blank','cp'); $hfield = '11'; } else if ( !cp_check_email($email) ) { $errmsg = __('Email address is not valid','cp'); $hfield = '12'; } else if($name_owner == '') { $errmsg = __('Name cannot be blank','cp'); $hfield = '13'; } else if($description == '') { $errmsg = __('The description cannot be blank','cp'); $hfield = '14'; }
// if there are no errors, then process the ad updates if($errmsg == '') { if ( get_option('filter_html') != "yes" ) { $description = cp_filter($description); }
// Put all post variables into an array $my_ad = array(); $my_ad['ID'] = trim($_POST['ad_id']); $my_ad['post_title'] = cp_filter($_POST['post_title']); $my_ad['post_content'] = $description;
//Add or edit images // First delete any images as posted $image_folder_name = "classipress"; $upload_arr = wp_upload_dir(); $imagedirectory = trailingsla****($upload_arr['basedir']) . $image_folder_name; $delimages=$_POST['delimages']; $noofdel=0; $notdel=0; $postedimages = explode(",", get_post_meta($my_ad['ID'], 'images', true)); $totalimages=count($postedimages); if (!empty($delimages)){ foreach ($delimages as $imagekey=> $delimage){ if ($delimage!=""){ $imagetodelete = $imagedirectory.'/'.basename($postedimages[$delimage]); $delstatus=unlink($imagetodelete); if($delstatus=="1"){ $noofdel++; // $listofdeleted=$delmessages.basename($postedimages[$delimage])." was deleted successfully.<br/>"; // can be used to see files being deleted array_splice($postedimages,$delimage,1); } else { $notdel++; // $listofnotdeleted=$delmessages.basename($postedimages[$delimage])." was not deleted<br/>"; // can be used to see files being deleted } } } $delmessages=$noofdel." images were deleted successfully<br/>".$listofdeleted; if($notdel!=0){ $delmessages.=$notdel."images were not deleted<br/>".$listofnotdeleted; } }
// Second Insert new images //1024 bytes = 1kb //1024000 bytes = 1mb // $image_folder_name = "classipress"; $size_bytes = 1024000; $size_mb = $size_bytes / 1024000; $limitedext = array(".gif",".png",".jpg",".jpeg");
// http://codex.wordpress.org/Function_Reference/wp_upload_dir // $upload_arr = wp_upload_dir();
// $dir_to_make = trailingsla****($upload_arr['basedir']) . $image_folder_name; // $dir_to_make = "wp-content/uploads/classipress"; $image_baseurl = trailingsla****($upload_arr['baseurl']) . $image_folder_name; $image_name = substr(sanitize_title(alphanumericAndSpace($title)), 0, 20); $i = rand(); $newimages = ""; $err2 = ""; while(list($key,$value) = each($_FILES['images']['name'])) { if(!empty($value)) { $filename = strtolower($value); $filename = str_replace(" ", "-", $filename); //get image extension $tipul = strrchr($filename,'.'); $filename = $image_name."-$i".$tipul; $add = "$imagedirectory/$filename"; $image = "$image_baseurl/$filename"; //$add = "$filename";
//Make sure that file size is correct $file_size = $_FILES['images']['size'][$key]; //getting the right size that coresponds with the image uploaded if ($file_size == "0"){ $err2 .= __('The file $value has 0 bytes.','cp') . "<br />"; } else { if ($file_size > $size_bytes){ $err2 .= __('The file $value is bigger than 2MB.','cp') . "<br />"; } } //check file extension $ext = strrchr($filename,'.'); if ( (!in_array(strtolower($ext),$limitedext)) ) { $err2 .= __('The file $value is not an image.','cp') . "<br />"; }
//echo $_FILES['images']['type'][$key]; if ( $err2 == "" ) { if (!file_exists($imagedirectory)) { mkdir($imagedirectory, 0777); } copy($_FILES['images']['tmp_name'][$key], $add); chmod("$add",0777);
//$images .= get_option('home')."/".$add.","; $newimages .= $image . ",";
} $err2 = ""; $i++; }//if empty $value }//end while
// Create new images array array_merge($postedimages); foreach ($postedimages as $image){ if ($image!=""){ $images=$images.$image.','; } }
// Update the ad in the db wp_update_post( $my_ad );
// now go back and update the meta fields update_post_meta($_POST['ad_id'], 'price', $price); update_post_meta($_POST['ad_id'], 'location', $location); update_post_meta($_POST['ad_id'], 'make', $make); update_post_meta($_POST['ad_id'], 'model', $model); update_post_meta($_POST['ad_id'], 'year', $year); update_post_meta($_POST['ad_id'], 'interior', $mileage); update_post_meta($_POST['ad_id'], 'exterior', $exterior); update_post_meta($_POST['ad_id'], 'interior', $interior); update_post_meta($_POST['ad_id'], 'doors', $doors); update_post_meta($_POST['ad_id'], 'email', $email); update_post_meta($_POST['ad_id'], 'name', $name_owner); update_post_meta($_POST['ad_id'], 'images',$images.$newimages); $cp_dashboard_url = $_POST['dashboard_url']; $errmsg = '<div class="box-yellow"><b>' .$delmessages. __('Your ad has been updated!','cp') . '</b><br /><br /> <a href=".' . $cp_dashboard_url . '">' . __('My Dashboard ››','cp') . '</a></div>'; } else { $errmsg = '<div class="box-red"><strong>** ' . $errmsg . ' **</strong></div>'; $errcolor = 'style="background-color:#FFEBE8;border:1px solid #CC0000;"'; }
}
// get the ad id from the querystring. Need this for the sql statement $aid = $_GET["aid"];
$querystr = "SELECT wposts.* FROM $wpdb->posts wposts WHERE ID = $aid AND post_status <> 'draft' AND post_author = $userdata->ID";
// pull ad fields from db $getmyad = $wpdb->get_row($querystr, OBJECT);
// start main edit page require_once dirname( __FILE__ ) . '/form_process.php';
get_header(); include_classified_form(); ?>
<style type="text/css"> .mid2 { border:1px solid #CCC; margin-bottom:10px; padding:5px; } </style>
<script type="text/javascript"> function textCounter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else cntfield.value = maxlimit - field.value.length; } </script>
<div class="content"> <div class="main ins"> <div class="left"> <div class="product">
<?php if (get_option('cp_ad_edit') != "no") { ?> <?php if ($getmyad): ?>
<?php echo $err2.$errmsg; ?>
<form name="edit_ad" id="edit_ad" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="ad_id" value="<?php echo $getmyad->ID; ?>" /> <input type="hidden" name="dashboard_url" value="<?php echo cp_dashboard_url; ?>" />
<h2><?php _e('Edit Your Ad','cp');?></h2> <p><?$delmessages?><p> <p><?php _e('Edit the fields below and click save to update your ad. Your changes will be updated instantly on the site.','cp');?></p>
<p><strong><?php _e('Ad ID:','cp');?></strong> <span style="background-color:#eee;padding:5px;"><?php echo $getmyad->ID; ?></span></p>
<p><label><b><?php _e('Title','cp');?></b> *<br /> <input <?php if ($hfield == '1') { echo $errcolor; } ?> type="text" name="post_title" class="mid2" id="post_title" value="<?php echo $getmyad->post_title; ?>" size="50" maxlength="100" /></label></p>
<p><label><b><?php _e('Price','cp');?></b> *<br /> <input <?php if ($hfield == '2') { echo $errcolor; } ?> type="text" name="price" class="mid2" id="price" value="<?php echo get_post_meta($getmyad->ID, "price", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('Location','cp');?></b> *<br /> <input <?php if ($hfield == '3') { echo $errcolor; } ?> type="text" name="location" class="mid2" id="location" value="<?php echo get_post_meta($getmyad->ID, "location", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('Make','cp');?></b> *<br /> <input <?php if ($hfield == '4') { echo $errcolor; } ?> type="text" name="make" class="mid2" id="make" value="<?php echo get_post_meta($getmyad->ID, "make", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('model','cp');?></b> *<br /> <input <?php if ($hfield == '5') { echo $errcolor; } ?> type="text" name="model" class="mid2" id="model" value="<?php echo get_post_meta($getmyad->ID, "model", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('year','cp');?></b> *<br /> <input <?php if ($hfield == '6') { echo $errcolor; } ?> type="text" name="year" class="mid2" id="year" value="<?php echo get_post_meta($getmyad->ID, "year", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('mileage','cp');?></b> *<br /> <input <?php if ($hfield == '7') { echo $errcolor; } ?> type="text" name="mileage" class="mid2" id="mileage" value="<?php echo get_post_meta($getmyad->ID, "mileage", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('exterior','cp');?></b> *<br /> <input <?php if ($hfield == '8') { echo $errcolor; } ?> type="text" name="exterior" class="mid2" id="exterior" value="<?php echo get_post_meta($getmyad->ID, "exterior", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('interior','cp');?></b> *<br /> <input <?php if ($hfield == '9') { echo $errcolor; } ?> type="text" name="interior" class="mid2" id="interior" value="<?php echo get_post_meta($getmyad->ID, "interior", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('doors','cp');?></b> *<br /> <input <?php if ($hfield == '10') { echo $errcolor; } ?> type="text" name="doors" class="mid2" id="doors" value="<?php echo get_post_meta($getmyad->ID, "doors", true); ?>" size="50" maxlength="100" /></label></p> <p><label><b><?php _e('Name','cp');?></b> *<br /> <input <?php if ($hfield == '13') { echo $errcolor; } ?> type="text" name="name_owner" class="mid2" id="name_owner" value="<?php echo get_post_meta($getmyad->ID, "name", true); ?>" size="50" maxlength="100" /></label></p>
<p><label><b><?php _e('Email','cp');?></b> *<br /> <input <?php if ($hfield == '12') { echo $errcolor; } ?> type="text" name="email" class="mid2" id="email" value="<?php echo get_post_meta($getmyad->ID, "email", true); ?>" size="50" maxlength="100" /></label></p> <p><b><?php _e('Description','cp');?></b> *<br /> <textarea <?php if ($hfield == '14') { echo $errcolor; } ?> name="description" class="mid2" id="description" rows="15" cols="57" onkeydown="textCounter(document.edit_ad.description,document.edit_ad.remLen1,5000)" onkeyup="textCounter(document.edit_ad.description,document.edit_ad.remLen1,5000)"><?php echo stripslashes($getmyad->post_content); ?></textarea></p>
<div class="limit"> <input readonly="readonly" type="text" name="remLen1" size="4" maxlength="4" value="5000" style="width: 50px;" /><span style="font-size:11px;"> <?php _e('characters left','cp'); ?></span> </div>
<p><b><?php _e('Images to be deleted','cp');?><small>(<?php _e('check images to be deleted','cp'); ?>)</small></b><br /> <? $matches = explode(",", get_post_meta($getmyad->ID, 'images', true)); foreach($matches as $key=>$var) { if ($var != "") { $thumb_var = str_replace(get_option('home')."/wp-content/uploads/classipress/", "", $var); $single_thumb_img_url = get_bloginfo('template_url')."/includes/img_resize.php?width=100&height=100&url=".$thumb_var; echo "<input type=\"checkbox\" name=\"delimages[]\" value=\"$key\"><img src=\"$single_thumb_img_url\"/>"; //echo "<a href=\"$var\" rel=\"group\"><img src=\"$single_thumb_img_url\" class=\"size-thumbnail\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" /></a>"."\n"; } else { if ( $matches[0] == "") { _e('There are no images','cp'); } } }
?>
<p><b><?php _e('Add images','cp'); ?> <small>(<?php _e('images must be under 1 MB','cp'); ?>)</small></b> <input type="file" name="images[]" class="wwIconified" value="<?php echo $_POST['images']; ?>"/><br /><p>
<p class="submit"><input type="submit" class="lbutton" value="<?php _e('Update Ad »','cp') ?>" name="submit" /></p> </form>
<?php else : ?>
<h2 class="center"><?php _e('Ad Not Found','cp');?></h2> <p class="center"><?php _e('Sorry, but you are looking for something that isn\'t here.','cp');?><br /> <?php _e('Go to','cp');?> <a href="<?php bloginfo('url')?><?php echo cp_dashboard_url; ?>"><?php _e('My Dashboard','cp');?> ››</a></p>
<?php endif; ?>
<?php } else { ?>
<h2 class="center"><?php _e('Ad Editing is Disabled','cp');?></h2> <p class="center"><?php _e('Your site administrator has disabled ad editing. Please contact them for further instructions.','cp');?><br /> <?php _e('Go to','cp');?> <a href="<?php bloginfo('url')?><?php echo cp_dashboard_url; ?>"><?php _e('My Dashboard','cp');?> ››</a></p>
<?php } ?>
</div> </div> <div class="right"> <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Page Sidebar')) : else : ?>
<?php endif; ?> <?php wp125_single_ad(1); ?> <?php wp125_single_ad(2); ?> <?php wp125_single_ad(3); ?> <?php wp125_single_ad(4); ?> <?php wp125_single_ad(5); ?> <?php wp125_single_ad(6); ?> <?php wp125_single_ad(7); ?> <?php wp125_single_ad(8); ?> <?php wp125_single_ad(9); ?> <?php wp125_single_ad(10); ?> <?php wp125_single_ad(11); ?> <?php wp125_single_ad(12); ?> <?php wp125_single_ad(13); ?> <?php wp125_single_ad(14); ?> </div> <div class="clear"></div> </div> </div>
<?php get_footer(); ?>
|
|
|
|
10-13-2009, 09:42 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 9,669
Name: Steven Bradley
Location: Boulder, Colorado
|
There's no action specified in the opening form tag
HTML Code:
<form*name="edit_ad"*id="edit_ad"*action=""*method="post"*enctype="multipart/form-data">
I see the original tpl-edit-ad.php also didn't specify a url for the form action. There must be something else controlling how the form gets submitted that got left out of the second file.
|
|
|
|
10-15-2009, 10:29 AM
|
Re: PHP Post/Edit forms not working!
|
Posts: 5
Name: Josh Harris
|
The form is used to edit Wordpress posts.
It works fine before the edits to add the extra fields which is what I cant understand.
|
|
|
|
10-15-2009, 09:29 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 9,669
Name: Steven Bradley
Location: Boulder, Colorado
|
Nothing is standing out to me as possibly causing the problem. I do see that form_process.php is included and I assume that's the file that processes the form given it's name.
Could you post the code in that file? Maybe it's something in there that needs to be edited.
|
|
|
|
10-16-2009, 07:54 AM
|
Re: PHP Post/Edit forms not working!
|
Posts: 5
Name: Josh Harris
|
Here is form_process.php
PHP Code:
<?php set_time_limit(0); if (isset($_POST['action']) && $_POST['action'] == 'post') {
if ( get_option("permissions") == "no" ) { if ( !is_user_logged_in() ){ wp_redirect( get_bloginfo( 'url' ) . '/' ); exit; }; }
check_admin_referer( 'new-post' ); $err = ""; $ok = ""; $user_id = $current_user->user_id; $post_title = cp_filter($_POST['post_title']); $post_cat = (int)cp_filter($_POST['cat']); $post_cat_array = array("$post_cat");
if ( get_option('filter_html') == "yes" ) { $description = trim($_POST['description']); // $description = addslashes($_POST['description']); // $description = str_replace("javascript", "", $description); } else { $description = cp_filter($_POST['description']); }
$name_ad = cp_filter($_POST['name_ad']); $phone = cp_filter($_POST['phone']); $price = cp_filter($_POST['price']); $location = cp_filter($_POST['location']); $make = cp_filter($_POST['make']); $year = cp_filter($_POST['year']); $model = cp_filter($_POST['model']); $mileage = cp_filter($_POST['mileage']); $exterior = cp_filter($_POST['exterior']); $interior = cp_filter($_POST['interior']); $doors = cp_filter($_POST['doors']); $fuel = cp_filter($_POST['fuel']); $name = cp_filter($_POST['name_owner']); $email = cp_filter($_POST['email']); // $title = cp_filter($_POST['title']); $post_tags = cp_filter($_POST['post_tags']); $cp_adURL = cp_filter($_POST['cp_adURL']); $featured_ad = cp_filter($_POST['featured_ad']); $ad_length = get_option("prun_period"); $expires = date('m/d/Y G:i:s', strtotime("+" . $ad_length . " days")); $images = strip_tags($_POST['images']);
$total = (int)$_POST['total']; $nr1 = (int)$_POST['nr1']; $nr1 = str_replace("892347", "", $nr1); $nr2 = (int)$_POST['nr2']; $nr2 = str_replace("234543", "", $nr2); $nr1nr2 = $nr1 + $nr2;
if ( $post_cat == "-1") { $err .= __('Please select a category','cp') . "<br />"; } else { global $wpdb; $cat_ids = (array) $wpdb->get_col("SELECT `term_id` FROM $wpdb->terms"); if ( !in_array($post_cat, $cat_ids) && $post_cat != "-1") { $err .= __('This category does not exist','cp') . "<br />"; } } if ($post_title == "" || $post_cat == "" || $price == "" || $location == "" || $name == "" || $email == "" || $description == "") { $err .= __('Please fill in all mandatory * fields','cp') . "<br />"; } if ( !cp_check_email($email) ) { $err .= __('Please enter a valid email','cp') . "<br />"; } if ( $total != $nr1nr2 ) { $err .= __('The spam field is incorrect','cp') . "<br />"; } if ( $err == "" ) {
//1024 bytes = 1kb //1024000 bytes = 1mb $image_folder_name = "classipress"; $size_bytes = 1024000; $size_mb = $size_bytes / 1024000; $limitedext = array(".gif",".png",".jpg",".jpeg");
// http://codex.wordpress.org/Function_Reference/wp_upload_dir $upload_arr = wp_upload_dir(); $dir_to_make = trailingsla****($upload_arr['basedir']) . $image_folder_name; // $dir_to_make = "wp-content/uploads/classipress"; $image_baseurl = trailingsla****($upload_arr['baseurl']) . $image_folder_name; $image_name = substr(sanitize_title(alphanumericAndSpace($post_title)), 0, 20); $i = rand(); $images = ""; $err2 = ""; while(list($key,$value) = each($_FILES['images']['name'])) { if(!empty($value)) { $filename = strtolower($value); $filename = str_replace(" ", "-", $filename); //get image extension $tipul = strrchr($filename,'.'); $filename = $image_name."-$i".$tipul; $add = "$dir_to_make/$filename"; $image = "$image_baseurl/$filename"; //$add = "$filename";
//Make sure that file size is correct $file_size = $_FILES['images']['size'][$key]; //getting the right size that coresponds with the image uploaded if ($file_size == "0"){ $err2 .= __('The file $value has 0 bytes.','cp') . "<br />"; } else { if ($file_size > $size_bytes){ $err2 .= __('The file $value is bigger than 2MB.','cp') . "<br />"; } } //check file extension $ext = strrchr($filename,'.'); if ( (!in_array(strtolower($ext),$limitedext)) ) { $err2 .= __('The file $value is not an image.','cp') . "<br />"; }
//echo $_FILES['images']['type'][$key]; if ( $err2 == "" ) { if (!file_exists($dir_to_make)) { mkdir($dir_to_make, 0777); } copy($_FILES['images']['tmp_name'][$key], $add); chmod("$add",0777);
//$images .= get_option('home')."/".$add.","; $images .= $image . ",";
} $err2 = ""; $i++; }//if empty $value }//end while
$post_code = time();
if ( get_option('activate_paypal') == "yes" ) { if (get_option('cp_price_scheme') == "category" ) { // if the ad cost is zero AND featured is not checked, then it should automatically be set to published $cat_price_check = get_option('cp_cat_price_'.$post_cat); // 0 if (($cat_price_check == "0") && ($featured_ad == "")) { $post_status = "publish"; } else { $post_status = "draft"; } } else { $post_status = "draft"; }
} else { $post_status = get_option("post_status"); }
$post_id = wp_insert_post( array( 'post_author' => $user_id, 'post_title' => $post_title, 'post_content' => $description, 'post_category' => $post_cat_array, 'post_status' => $post_status, 'tags_input' => $post_tags ) ); add_post_meta($post_id, 'location', $location, true); add_post_meta($post_id, 'make', $make, true); add_post_meta($post_id, 'year', $year, true); add_post_meta($post_id, 'model', $model, true); add_post_meta($post_id, 'mileage', $mileage, true); add_post_meta($post_id, 'exterior', $exterior, true); add_post_meta($post_id, 'interior', $interior, true); add_post_meta($post_id, 'doors', $doors, true); add_post_meta($post_id, 'fuel', $fuel, true); add_post_meta($post_id, 'price', $price, true); add_post_meta($post_id, 'name', $name, true); add_post_meta($post_id, 'email', $email, true); add_post_meta($post_id, 'phone', $phone, true); add_post_meta($post_id, 'images', $images, true); add_post_meta($post_id, 'expires', $expires, true); add_post_meta($post_id, 'cp_adURL', $cp_adURL, true); if ($featured_ad == 1 ) { stick_post($post_id); // if they checked the box and paid for a featured ad, then make the post sticky } $ok = "ok";
// send notification email if ( get_option('notif_ad') == "yes" ) { $user_info = get_userdata(1); $admin_email = $user_info->user_email; $subject2 = __('New ad submission','cp'); $email2 = __('ClassiPress','cp'); $body = __('Someone has submitted a new ad. Go to your admin panel to view it.','cp') . "\n\n" . get_option('home')."/wp-admin/edit.php"; wp_mail($admin_email,$subject2,$body,"From: $email2"); }
if ( get_option('activate_paypal') == "yes" ) { $post_title = str_replace(" ", "+", $post_title); wp_redirect( get_bloginfo( 'url' ) . '/?ok=ok&title='.$post_title.'&id='.$post_id.'&catid='.$post_cat.'&fid='.$featured_ad.'&lprice='.$price ); } else { wp_redirect( get_bloginfo( 'url' ) . '/?ok=ok' ); } exit; } }
?>
|
|
|
|
10-16-2009, 08:43 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 9,669
Name: Steven Bradley
Location: Boulder, Colorado
|
I'm still not seeing anything. Sorry I haven't been able to help more.
I could understand if after you added the fields there was an error, but not why you get the page can not be displayed errors. Are there specific errors or is that all it says?
|
|
|
|
10-17-2009, 12:39 PM
|
Re: PHP Post/Edit forms not working!
|
Posts: 22,225
Location: Blackpool. UK
|
Quote:
|
I've edited the edit form to add the fields,
|
Make sure the page is not now called whatever.php.txt (depending on what you used to edit it.
|
|
|
|
|
« Reply to PHP Post/Edit forms not working!
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|