Post method not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nishant1984
Forum Newbie
Posts: 1
Joined: Fri Jan 13, 2012 5:35 pm

Post method not working

Post by Nishant1984 »

Hi Friends,

I have created form using simfatic forms to collect some user information but I am not able to pass the variable data to my Php file using post method. ( I am using Xampp to run my code.)

My form is as follow:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head >
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title >Form Page: PostAdd</title>
<script src='scripts/gen_validatorv5.js' type='text/javascript'></script>
<script src='scripts/sfm_moveable_popup.js' type='text/javascript'></script>
<script src='scripts/decimal.js' type='text/javascript'></script>
<script src='scripts/sfm-png-fix.js' type='text/javascript'></script>
<script src='scripts/sfm_captcha_validator.js' type='text/javascript'></script>
<link rel='stylesheet' type='text/css' href='style/PostAdd.css'/>
</head>
<body style='background-color:transparent'>
<form id='PostAdd' method='POST' action='Formprocessor.php' accept-charset='UTF-8'>
<div id='PostAdd_errorloc' class='error_strings' style='width:355px;text-align:left'></div>
<div id='PostAdd_outer_div' style='width:355px;height:517px;background-color:#d8d8ed'>
<div style='position:relative' id='PostAdd_inner_div'>
<input type='hidden' name='sfm_form_submitted' value='yes'/>
<div id='heading_container'>
<div id='heading'>Post Your Advertise</div>
</div>
<div id='FCategory_container'>
<select name='FCategory' id='FCategory' size='1'>
<option value='01' selected="selected">Engineering</option>
<option value='02'>Management</option>
<option value='03'>Medical</option>
<option value='04'>Competitive Exams </option>
<option value='05'>Science</option>
<option value='06'>Commerce</option>
<option value='07'>Arts</option>
<option value='08'>General</option>
</select>
</div>
<div id='label_container'>
<label id='label' for='Fcategory' class='sfm_form_label'>Book category</label>
</div>
<div id='label1_container'>
<label id='label1' for='FBookName' class='sfm_form_label'>Book Name</label>
</div>
<div id='FBookName_container'>
<input type='text' name='FBookName' id='FBookName' size='20' class='sfm_textbox'/>
</div>
<div id='label2_container'>
<label id='label2' class='sfm_form_label'>Book Description</label>
</div>
<div id='FBookDescription_container'><textarea name='FBookDescription' id='FBookDescription' cols='50' rows='10' class='sfm_textarea'></textarea></div>
<div id='label3_container'>
<label id='label3' for='FbookPrice' class='sfm_form_label'>Selling Price</label>
</div>
<div id='FbookPrice_container'>
<input type='text' name='FbookPrice' id='FbookPrice' onkeypress='return sfm_decimal_key_handler(this, event,".")' value='0'/>
</div>
<div id='label4_container'>
<div id='label4'>Your contact Details</div>
</div>
<div id='FCity_container'>
<input type='text' name='FCity' id='FCity' size='20' class='sfm_textbox'/>
</div>
<div id='label6_container'>
<label id='label6' for='FCity' class='sfm_form_label'>City </label>
</div>
<div id='Email_container'>
<input type='text' name='Email' id='Email' size='20' class='sfm_textbox'/>
</div>
<div id='label7_container'>
<label id='label7' for='Email' class='sfm_form_label'>Email</label>
</div>
<div id='label8_container'>
<label id='label8' for='Phone' class='sfm_form_label'>Phone</label>
</div>
<div id='Phone_container'>
<input type='text' name='Phone' id='Phone' size='20' class='sfm_textbox'/>
</div>
<div id='HyperLink_container'>
<a id='HyperLink' href='http://PinInfo'>What is this?</a>
</div>
<div id='FPin_container'>
<input type='password' name='FPin' id='FPin' size='20' class='sfm_textbox'/>
</div>
<div id='label9_container'>
<label id='label9' for='FPin' class='sfm_form_label'>Pin</label>
</div>
<div id='FSubmit_container'>
<input type='Submit' name='FSubmit' id='PostAdd_FSubmit_img' src='images/PostAdd-FSubmit-0.png' onClick= alt='submit'/>
</div>
<div id='Captcha1_container'>
<div >
<img class='sfm_captcha' id='img_Captcha1' src='Formprocessor.php?sfm_get_captcha=1' width='150' height='60' alt='Captcha'/>
</div>
<div class='element_label'>Please enter the code above in the box below.</div>
<div >
<input type='text' name='sfm_captcha_Captcha1'/>
</div>
<div class='element_label'>
<small >Can't read the image? Please click <a href="javascript: refresh_captcha_img_Captcha1()" >here</a> to refresh</small>
</div>
</div>
</div>
</div>

</form>
<script type='text/javascript'>
// <![CDATA[
document.getElementById("HyperLink").target = "_top";
sfm_fix_png("PostAdd_FSubmit_img","images/spacer.gif");
function refresh_captcha_img_Captcha1()
{
var img = document.images['img_Captcha1'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?sfm_get_captcha=1&rand="+Math.random()*1000;
}
document.forms['PostAdd'].sfm_captcha_Captcha1.validator
= new SFM_CaptchaValidator(document.forms['PostAdd'].sfm_captcha_Captcha1);
function sfm_captcha_Captcha1_Validate()
{
var captcha_ip = arguments[0];
return captcha_ip.validator.validate();
}

if(document.sfm_after_load != undefined){document.sfm_after_load();}

// ]]>
</script>
<script type='text/javascript'>
// <![CDATA[
var PostAddValidator = new Validator("PostAdd");

PostAddValidator.EnableOnPageErrorDisplay();
PostAddValidator.SetMessageDisplayPos("right");

PostAddValidator.EnableMsgsTogether();
PostAddValidator.addValidation("FBookName","req","Please fill in FBookName");
PostAddValidator.addValidation("FBookName","maxlen=50","The length of the input for FBookName should not exceed 50");
PostAddValidator.addValidation("FBookName","minlen=5","The length of the input for FBookName should be at least 5.");
PostAddValidator.addValidation("FBookName","alnum","The input for FBookName should be a valid alpha-numeric value");
PostAddValidator.addValidation("FBookDescription","maxlen=1000","The length of the input for FBookDescription should not exceed 1000");
PostAddValidator.addValidation("FbookPrice","numeric","The input for should be a valid numeric value");
PostAddValidator.addValidation("FCity","req","Please fill in FCity");
PostAddValidator.addValidation("FCity","alnum","The input for FCity should be a valid alpha-numeric value");
PostAddValidator.addValidation("FCity","maxlen=50","The length of the input for FCity should not exceed 50");
PostAddValidator.addValidation("FCity","minlen=2","The length of the input for FCity should be at least 2.");
PostAddValidator.addValidation("Email","email","The input for Email should be a valid email value");
PostAddValidator.addValidation("Email","req","Please fill in Email");
PostAddValidator.addValidation("Phone","numeric","The input for Phone should be a valid numeric value");
PostAddValidator.addValidation("Phone","maxlen=15","The length of the input for Phone should not exceed 15");
PostAddValidator.addValidation("FPin","req","Please fill in FPin");
PostAddValidator.addValidation("FPin","numeric","The input for FPin should be a valid numeric value");
PostAddValidator.addValidation("FPin","maxlen=4","The length of the input for FPin should not exceed 4");
PostAddValidator.addValidation("FPin","minlen=4","The length of the input for FPin should be at least 4.");
PostAddValidator.addAddnlValidationFunction(sfm_captcha_Captcha1_Validate,document.forms['PostAdd'].sfm_captcha_Captcha1);

// ]]>
</script>
</body>
</html>


Formprocessor.php

<?php
Echo "I am in Forprocessor";
$Category = $_POST['FCategory'];
$BookName = $_POST['FBookName'];
$BookDescription = $_POST['FBookDescription'];
$BookPrice = $_POST['FbookPrice'];
$City = $_POST['FCity'];
$Email = $_POST['Email'];
$Phone = $_POST['Phone'];
$Pin = $_POST['FPin'];
?>

I am getting error as Undefined index:FCategory
similar message is coming for rest variables as well.


Thank you for your help in advance...
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Post method not working

Post by social_experiment »

http://tinyurl.com/yu57xj
Have a look at this url; if possible paste the code on the processing (Formprocessor) page
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply