PHP - !isset Function Not Working
For some reason the !isset() function doesnt seem to work i cant find out why hope you guys will be able to help
Here is the html code for the form where the user enters the data Code: [Select] <div id="contact_form"> <h2>On Site SEO Signup Form</h2> <form method="post" name="contact" action="http://www.techbreeze.in/freeseo.php"> <label for="uname">Name:</label> <input name="uname" type="text" class="required input_field" id="uname" /> <div class="cleaner h10"></div> <label for="email">Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" /> <div class="cleaner h10"></div> <label for="website">Website:</label> <input type="text" class="required input_field" id="website" name="website"/> <div class="cleaner h10"></div> <label for="ftp">Your FTP Login URL:</label> <input type="text" class="required input_field" id="url" name="url" /> <div class="cleaner h10"></div> <label for="username">Your FTP Username:</label> <input type="text" class="required input_field" id="user" name="user" /> <div class="cleaner h10"></div> <label for="password">Your FTP Password:</label> <input type="password" class="required input_field" id="pass" name="pass"/> <div class="cleaner h10"></div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> </div> And here is the code for the .php file where the !isset() function is used Code: [Select] <?php // validation expected data exists if( !isset($_POST['uname'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Name" field empty!'); } if( !isset($_POST['pass'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Password" field empty!'); } if( !isset($_POST['email'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Email" field empty!'); } if( !isset($_POST['website'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Website" field empty!'); } if( !isset($_POST['url'])) { die ('We are sorry, but all the fields are necessary you cant leave the "FTP URL" field empty!'); } if( !isset($_POST['user'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Username" field empty!'); Thanks in advance Similar TutorialsI have a simple log in form. By debugging I found that isset post submit function is not responding. It remains on the same page after submitting form. I have googled all the possible solutions to this problem but none worked. Any help is greatly appreciated. The form is in multiplelogin.php file and the code is in multi.php file. After login redirection is to teachers.php file. <?php session_start(); $conn = mysqli_connect("localhost", "root", "", "signup");
if(isset($_SESSION['username'])) {
?>
<head> <link rel="stylesheet" type="text/css" href="bootstrap.css"> <title> Teachers Students Login </title> </head> <body class="bg-secondary"> <div class="container"> <div class="row justify-content-center"> <div class="col-log-5 bg-light mt-5 px-0"> <h3 class="text-center text-light bg-primary py-3 px-5"> Log In </h3>
<div class="form-group px-5"> <input type="email" name="email" class="form-control form-control-lg" placeholder="Email" required> </div> <div class="form-group px-5"> <input type="password" name="password" class="form-control form-control-lg" placeholder="Password" required> </div> <div class="form-group px-5"> <input type="submit" name="submit" value="Submit" class="btn btn-primary btn-block"> </div> </form> </div> </div> </div>
<?php
ini_set( 'display_errors', 1 );
$password = $_POST['password'];
$stmt = mysqli_stmt_init($conn); header("Location: multilogin.php?error=sqlerror"); exit();
} else { mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($pwdCheck == false) {
exit(); $_SESSION['username'] = $row['username']; $_SESSION['email'] = $row['email']; header("Location: teachers.php?login=success");
exit ();
exit();
exit();
else {
exit(); Hi, just began working with the isset function, and having a few problems with the following code. As you can see I'm trying to assign some variables using the explode function. This is the string that is taken from the form on my index page http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/refresh_stat_manual?user_id=100000898907997&auth_key=e5f4a2308d13346b4bf6e8228e9f50636240bf9f&nocache=1290001265332& $RawHeader = str_replace(' ', '', $_POST['RawHeader']); if (isset($RawHeader)) { $UserID = explode('user_id=', $RawHeader); $UserID = explode('&', $UserID[1]); $UserID = $UserID[0]; $AuthKey = explode('auth_key=', $RawHeader); $AuthKey = explode('&nocache=', $AuthKey[1]); $AuthKey = $AuthKey[0]; } I am new to the isset function so I don't really know if there is anything wrong with it, but if I try echo out both $UserID and $AuthKey it returns nothing. Any suggestions or solutions? Thanks The below should be making it so that in order for "customer reviews" to be visible, you should need the "&review" in the url, but it's coming up regardless if it's in the URL or not. http://ghosthuntersportal.com/store.php?product=2 Code: [Select] elseif(isset($_GET['product'])){ $product_id=$_GET['product']; $sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'"; $result500=mysql_query($sql500); $num_rows500=mysql_num_rows($result500); if($num_rows500==0){ $average_rating=0; } else{ while($row500=mysql_fetch_array($result500)){ extract($row500); $total = $total + $review_product_rating; $review.=' <div class="review_container"> <div>'.$review_product_rating.' '.$review_title.'</div> <div>By '.$review_name.' from '.$review_location.' on '.$review_date.'</div> <div>Pros: </div><div>'.$review_pros.'</div> <div>Cons: </div><div>'.$review_cons.'</div> <div>Describe Yourself: </div><div>'.$review_describe.'</div> <div>Best Use: </div><div>'.$review_best_use.'</div> <div>'.$review_text.'</div> </div> '; } $review_product_rating_total=$total; $average_rating=$review_product_rating_total/$num_rows500; } $sql50="SELECT * FROM $tbl_name WHERE product_id='$product_id'"; $result50=mysql_query($sql50); while($row50=mysql_fetch_array($result50)){ extract($row50); $section=ucwords($product_category); $product_name=ucwords($product_name); $crumbs='<a href="./index.php">Home</a> <span class="eleven">></span> <a href="./store.php?cat='.$product_category.'">'.$section.'</a> <span class="eleven">></span> <a href="./store.php?product='.$product_id.'">'.$product_name.'</a>'; $section=" - ".$section; $product_highlights=str_replace("[","<li>", $product_highlights); $product_highlights=str_replace("]","</li>", $product_highlights); $content.=' <div class="product_wrapper"> <div>'.$product_name.'</div> <div class="product_image"> <div><img src="'.$product_image.'" alt="'.$product_name.'" /></div> </div> <div class="product_details"> <div class="product_price">Price: $'.$product_price.'</div> <div class="product_code">GHP#: '.$product_code.'</div> <div class="rating_image">'; if($num_rows500==0){ $content.='No Rating'; } else{ $content.='<img src="'.$average_rating.'.png" alt="'.$average_rating.'" />'; } $content.=' <span class="twelve">('.$num_rows500.' Reviews)</span></div><div>'; if(isset($product_highlights)){ $content.='<div class="product_highlights_text">Product Highlights</div><div class="product_highlights_item"><ul>'.$product_highlights.'</ul></div>'; } else{ } $content.='</div> </div> </div> '; } $content.='<div class="product_links_headers">Overview | Specifications | Customer Reviews</div>'; if(isset($review)){ $content.='<div style="margin-top: 400px;">'.$review.'</div>'; } elseif(isset($specifications)){ $content.='<div style="margin-top: 400px;">'.$product_specifications.'</div>'; } else{ } } Code: [Select] if (isset($_COOKIE['hide_div']['0']) && isset($_COOKIE['hide_div']['2'])){ $cookie1 = $_COOKIE['hide_div']['0']; $cookie2 = $_COOKIE['hide_div']['2']; } if ($cookie1 == $cat_id OR $cookie2 == $cat_id) { foreach ($this->forums as $forum_id => $forum_data) { if ($forum_data['category'] == $cat_id) { //----------------------------------- // We store the HTML in a temp var so // we can make sure we have cats for // this forum, or hidden forums with a // cat will show the cat strip - we don't // want that, no - we don't. //----------------------------------- $temp_html .= $this->process_forum($forum_id, $forum_data); } } if ($temp_html != "") { $this->output .= $this->html->CatHeader_Expandedhidden($cat_data); $this->output .= $this->html->end_this_cat(); } unset($temp_html); }else{ $cookie1 = ''; $cookie2 = ''; why in the world is it displaying Undefined variable: cookie1 and cookie2 as errors? When I declared both of them even AFTER my if statement, this is bogus dude, lol this isset stuff is really confusing or am i just not doing it right? Im trying to use an if isset to stop my error messages displaying before they submit the form it worked on another part of my website but wont work for this, It just wond submit the form at all when i click submit here is the code: <html> <head> </head> <body> <form action="contact.php" method="post"> <fieldset> <legend>Contact Us</legend> Your Email:*<br> <input type="text" name="email"><br> Subject:*<br> <select name="subject"> <option value=""></option> <option value="1">Recruitment</option> <option value="2">Absense</option> <option value="3">Enquiry</option> </select> <br> Message:*<br> <textarea name="message" cols="50" rows="5"></textarea><br> <?php require_once('recaptchalib.php'); $publickey = "6LeB8LwSAAAAAKwvC3HWJNwWw9vYiSEkvFEvDduD"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <br> <input type="submit" value="Send Email"> </form> Required fields are marked with a *<br><br> <?php if(isset($_POST['Submit'])){ $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $to = "nathan_k_boothby_1994@hotmail.co.uk"; //checcking that all relevent information is entered and correct if(!$message || !$email) { $errmessage ="Please fill in all required data."; } require_once('recaptchalib.php'); $privatekey = "6LeB8LwSAAAAAA_0IIEnAxL5uOau0TBm83Iog7Ey"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $errmessage ="The text you wrote did not match the image."; } //Sending the email if nothing is wrong if(!$errmessage) { header("location:send.php?to=".$to."&subject=".$subject."&email=".$email."&message=".$message.""); }else{ echo $errmessage; } } ?> </fieldset> <br><br><br> </body> </html> And here is a link to the page: http://valiantflight.comlu.com/emailer/contact.php Any help will be greatly appriciated, Thanks, Blink359 Hi there, I have just move hosts with our website and it loads the frontpage but non of the subsequent pages. The site works like this, depending on the variables in the address depends which page and which template are loaded into it. If the template is "ros" it loads rosettes template, if it is "tro" it loads trophy template, and then the name of the item, ie "hazel" will load up the hazel product page. All it is doing at the moment is loading the home.php page. The code to do this is below: <? if (!isset($template)) {include ("static/home.php");} else if (isset($id)) { if (!file_exists("site_templates/$template.php")) { echo "OOPS! <P> The template you have requested does not exist!<BR><BR><BR><BR><BR><BR>"; }elseif (file_exists("site_templates/$template.php")) { include ("site_templates/$template.php"); } } ?> It worked with our last host, but refuses to work now. Is there someone out there that can help. Thanks in advance, Phil I am an absolute beginner in php & am trying to validate a form using javascript. Problem is I am checking if the textbox is left empty before the user clicks on the submit button(using javascript). On the other hand i'm using isset function of php for the same submit button so that it does not run the code unless and until the button is clicked. Due to this, the default value of text box is being entered into database. How do i prevent this? Is there an alternate function to isset for such an event? Here is a sample code Code: [Select] <?php if(isset($_POST[sub])) $sql="insert into testing values('$_POST[txt1]')"; $exec = mysql_query($sql); ?> <script type="text/javascript"> function check() { var a = document.getElementById('add'); if (a.value = "") { return false; } } </script> <form action="add.php" method="post"> <input type="text" name="txt1" id="add"><br> <input type="submit" name="sub" value="Click to Add" onclick = "check();"> </form> I'm using ghost text technique on my page instead of labels so the text boxes have different values at different instances and hence I cant use !empty function either. How do i unset the submit button so that it does not run the script further? Sorry for the miss spell on correctly counldn't edit the title
I need to have the following 3 varibles checked to see if they are set and if not display an error saying "All fields need to be filled in." My problem is that it's not working. Did I mess up on my if statement? $tempneeded $lowtemp $gallons <?php $tempneeded = $_POST['tempneeded']; $lowtemp = $_POST['lowtemp']; $gallons = $_POST['gallons']; htmlspecialchars($tempneeded, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lowtemp, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($gallons, ENT_QUOTES, 'UTF-8') . ' ' . $wgd = .5; $tempdiff = $tempneeded - $lowtemp; $wattsneeded = $tempdiff * ($gallons * $wgd); if (!isset ($lowtemp,$tempneeded,$gallons)) { echo "<b>All fields need to be filled in.</b>"; } else { echo "<b>You will need a total of $wattsneeded watts to rasie your tempature $tempdiff degress, from $lowtemp to $tempneeded.</b></td></tr>"; } ?> Edited by msebar, 08 October 2014 - 01:43 PM. I've tried both of these methods, but neither are working. The if statement fails every time. Code: [Select] if(isset($_POST['submit'])){ Code: [Select] if(isset($submit)){ This is the form: Code: [Select] <form id="form1" name="form1" method="post" action="join.php"> <label><span> <input name="email" type="text" class="keywords" id="textfield" maxlength="50" value="Join my mailing list..." onclick="make_blank();" /> </span> <input name="submit" type="image" src="images/search.gif" class="button" onclick="return checkmail(this.form.email);"/> </label> </form> Hello! This may sound like a stupid question but i have been trying to get this working all day and its driving me crazy.
Ive been asked to take over development of this project, he sent me his code and its a little out of date so im trying to update it. Here is what i cant work out.
I have this little snippet of code:
if ($page == "showthread"){ showThread(); }There are several more like that, but you dont need a whole list. That code seems to be throwing up this error when i go to that specific page: Notice: Undefined index: error in ..... All well and good, i would usually do this: if (isset($page) == "showthread"){ showThread(); }Thats fine and dandy, the error goes away. But now, when i go to that page, it redirects me and gives me my error message for a non-existing page. Its really frustrating me. Can you help me fix this little error? soory guys .. actually i am trying to add pagination in script.. but its not pagging.
but when i tried without isset($_get the code worked fine and then i tried to doing with isset($_get for a perticular cat
but its not working. can someone see my code and tell me whats worng i have done.
<!DOCTYPE HTML> <html> <head> </head> <body> <?php // include database connection include 'libs/db_connect.php'; // page is the current page, if there's nothing set, default is page 1 $page = isset($_GET['page']) ? $_GET['page'] : 1; // set records or rows of data per page $recordsPerPage = 1; // calculate for the query LIMIT clause $fromRecordNum = ($recordsPerPage * $page) - $recordsPerPage; // select all data $query = "SELECT * FROM posts ORDER BY post_id desc LIMIT {$fromRecordNum}, {$recordsPerPage}"; /* page and its LIMIT clause looks like: 1 = 0, 5 2 = 5,10 3 = 10,15 4 = 15, 20 5 = 20, 25 */ $stmt = $con->prepare( $query ); $stmt->execute(); //this is how to get number of rows returned $num = $stmt->rowCount(); //check if more than 0 record found if($num>0){ $cat=1; if(isset($_GET['cat'])){ $cat_id = $_GET['cat']; $get_posts = "select * from posts where category_id = '$cat_id'"; $run_posts = mysql_query($get_posts); while($row_posts = mysql_fetch_array($run_posts)){ $post_id = $row_posts['post_id']; $post_title = $row_posts['post_title']; $post_date = $row_posts['post_date']; $post_author = $row_posts['post_author']; $post_image = $row_posts['image']; $post_content = substr($row_posts['post_content'],0,80); echo " <div class='post_area'> <h4> <a href = 'details.php?post=$post_id'>$post_title</a> </h4> <div class='date'><div id='com'> Date</div>$post_date</div><span style='font-size:12px'><i style='color:grey;font-size:10px'>Posted By</i> </b>$post_author</span> <content><img src = '123dondadatest/news_images/$post_image' width = '100' height='100'/> <div>$post_content <br/><a id='rmlink' href = 'details.php?post=$post_id'> Read More...</a></div><br /><br/><br/><br/> </div> "; } } // *************** <PAGING_SECTION> *************** echo "<div id='paging'>"; // ***** for 'first' and 'previous' pages if($page>1){ // ********** show the first page echo "<a href='" . $_SERVER['PHP_SELF'] . "' title='Go to the first page.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> << </span>"; echo "</a>"; // ********** show the previous page $prev_page = $page - 1; echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$prev_page}' title='Previous page is {$prev_page}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> < </span>"; echo "</a>"; } // ********** show the number paging // find out total pages $query = "SELECT COUNT(*) as total_rows FROM posts"; $stmt = $con->prepare( $query ); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $total_rows = $row['total_rows']; $total_pages = ceil($total_rows / $recordsPerPage); // range of num links to show $range = 2; // display links to 'range of pages' around 'current page' $initial_num = $page - $range; $condition_limit_num = ($page + $range) + 1; for ($x=$initial_num; $x<$condition_limit_num; $x++) { // be sure '$x is greater than 0' AND 'less than or equal to the $total_pages' if (($x > 0) && ($x <= $total_pages)) { // current page if ($x == $page) { echo "<span class='customBtn' style='background:red;'>$x</span>"; } // not current page else { echo " <a href='{$_SERVER['PHP_SELF']}?page=$x' class='customBtn'>$x</a> "; } } } // ***** for 'next' and 'last' pages if($page<$total_pages){ // ********** show the next page $next_page = $page + 1; echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$next_page}' title='Next page is {$next_page}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> > </span>"; echo "</a>"; // ********** show the last page echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$total_pages}' title='Last page is {$total_pages}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> >> </span>"; echo "</a>"; } echo "</div>"; // ***** allow user to enter page number echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='GET'>"; echo "Go to page: "; echo "<input type='text' name='page' size='1' />"; echo "<input type='submit' value='Go' class='customBtn' />"; echo "</form>"; // *************** </PAGING_SECTION> *************** } // tell the user if no records were found else{ echo "<div class='noneFound'>No records found.</div>"; } ?> </body> </html> I have a long list of variables with form fields inserted into them like this: $page_id = $_POST['exclude']; I just turned on WP_Debug just to see which error messages would come up and to my surprise it wasn't that bad, the most error messages were "Call to Undefined function". The solution to this problem is simple, all I have to do is wrap an isset around all the form field variables, like this: $page_id = isset($_POST['exclude']); My question is, is this really necessary or considered as good practice? Should I now go ahead and wrap to all the variables in that long list an isset around? Or should I just turn WP_Debug off again and leave it as is? I personally would like to adopt to the good practice way, but I don't know how much of an advantage it is to wrap an isset around every single form field variable. Any suggestions? I am trying to make a ban function and i have the users id being passed through the URL and i can't seem to get it working.
<?php require 'connect.php'; include 'header.php'; error_reporting(E_ALL | E_NOTICE); session_start(); $ban = "SELECT id FROM $tbl_name WHERE id={$_GET['id']} AND active='$active'"; $banres = $con->query($ban); $row = $con->fetch_assoc($banres); $active = $row['active']; if($banres) { $active_update = "UPDATE $tbl_name SET active=0"; } ?> I have this code on my user registration form Code: [Select] <?php $flg = ""; $error = ""; if (isset($HTTP_GET_VARS["flg"])) $flg = $HTTP_GET_VARS["flg"]; switch ($flg) { case "yellow": $error = "<br><font class=\"txt12_red\">That Email Address already exists in our Database.<br>Please Select Another.<BR></font>"; break; case "red": $error = "<br><font class=\"txt12_red\">Please fill out all the required fields.<br>Please Try Again.<BR></font>"; break; case "blue": $error = "<br><font class=\"txt12_red\">Your Session has Expired.<br>Please Login Again.</font><BR>"; break; case "pink": $error = "<br><font class=\"txt12_red\"><BR>The Special Code you entered is not valid.<br>Please Try Again or Leave that field blank. </font><BR>"; break; case "white": $error = "<br><font class=\"txt12_red\"><BR>The fields are too long for our Database.<br>Please correct your data via this form.</font> <BR>"; break; default: $error = ""; } ?> and the registered form / page I have this validation and function Code: [Select] <?php // check to see if these variables have been set... if ((!isset($_SESSION["fname"])) || (!isset($_SESSION["lname"])) || (!isset($_SESSION["email"])) || (!isset($_SESSION["phone"])) || (!isset($_SESSION["city"])) || (!isset($_SESSION["status"])) || (!isset($_SESSION["province"]))) { resendToForm("?flg=red"); } // form variables must have something in them... if ($_SESSION['fname'] == "" || $_SESSION['lname'] == "" || $_SESSION['email'] == "" || $_SESSION['phone'] == "" || $_SESSION['city'] == "" || $_SESSION['status'] == "" || $_SESSION['province'] == "") { resendToForm("?flg=red"); } // make sure fields are within the proper range... if (strlen($_SESSION['fname']) > 35 || strlen($_SESSION['lname']) > 35 || strlen($_SESSION['email']) > 35 || strlen($_SESSION['phone']) > 35 || strlen($_SESSION['city']) > 35 || strlen($_SESSION['status']) > 35 || strlen($_SESSION['province']) > 35 || strlen($_SESSION['password']) > 30) { resendToForm("?flg=white"); } function resendToForm($flags) { reset ($_POST); // store variables in session... while (list ($key, $val) = each ($_POST)) { $_SESSION[$key] = $val; } // go back to the form... //echo $flags; header("Location: ./registration_form.php".$flags); exit; } ?> The validation is working as it goes back to user registration form, the problem is it's not displaying the error on Code: [Select] <?php echo $error; ?> What seems to be the problem? anyone? This is the function I wrote function getParagraph($myfile) { while (!feof($myfile)){ $data = fgets($myfile); $paragraph = explode("\n", $data); } return $paragraph; } When I print the array, it's empty. while ($paragraph = getParagraph($file)){ print_r($paragraph); } Prints to my webpage as: Array ( => ) The file is NOT empty, and it is formated by line breaks so I don't know what's not working. Hi all , in my scripts I have a drop list and its <option> values are retrieved from sql database , and once I choose any value from the drop list the value will shown in a textbox . It's functioning well in firefox and opera except IE , is there any way to solve this problem? Code: [Select] <html> <head> <title>Untitled</title> </head> <body> <form name="theform" onsubmit="CheckForm()"> <?php $query="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($query); ?> <select name="myOptions" onchange="document.theform.showValue.value=this.value" > <? while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option >$nt[Custgroup]</option>"; } ?> <input type="text" name="showValue"><br> </form> </body> </html> Thanks for every reply . deleting works, but can't seem to get the add to work???? any ideas Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search User</title> <link href="stylesheet1.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <style type="text/css"> body { font-size:12px; font-family:Arial, Helvetica, sans-serif; } form { display:block; width:260px; } form .input{ width:120px; float:right; } form label { display:block; width:260px; clear:both; } form textarea { display:block; width:260px; } </style> <script type="text/javascript"> // alert("document loaded 1"); // $(document).ready(function(){ //$("#projectid").html("1"); // alert("document loaded 1"); function userlistgenerate(){ var data = { "operation" : "userlist", "users": [ { "userid" : "usr_id"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('UserSearchPBT.php', { data: dataString}, userlistResult, "text"); $("#selectedUserName").html(""); // $("selectedUserName").hide("fast"); } function userlistResult(res) { var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#userlist").html(obj.ResultData); $("#selectedUserName").html(""); //$("selectedUserName").hide("fast"); } function UserSearchChoose(userid,username ,name,surname,email,phone,mobphone,isactive){ $("#userid").val(userid); $("#username").val(username); $("#name").val(name); $("#surname").val(surname); $("#email").val(email); $("#phone").val(phone); $("#mobphone").val(mobphone); $("#isuseractive").val(isactive); $("#useradd").hide("fast"); } function usersearch() { $("#useradd").show(); var name=$("#name").attr("value"); var surname=$("#surname").attr("value"); var data = { "operation" : "usersearch", "user": [ { "name" : name, "surname" : surname } ] // end of sales array } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, usersearchResult, "text"); } function usersearchResult(res) { var obj = $.evalJSON(res); $("#userlist").html(obj.ResultData); } function userdelete() { var useridval = $("#userid").attr("value"); alert (useridval); var data = { "operation" : "teamdelete", "userid" : useridval } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, userdeleteResult, "text"); } function userdeleteResult(res) { var obj = $.evalJSON(res); $("#successfailmessage").html(obj.SuccFailMessage); userlistgenerate(); } function useradd() { //alert ("team add a geliyor"); var userId = $("#userid").attr("value"); var username = $("#username").attr("value"); var usersurname = $("#surname").attr("value"); var useremail = $("#useremail").attr("value"); var userphone = $("#userphone").attr("value"); var usermob = $("#usermob").attr("value"); var useractive = $("#useractive").attr("value"); // alert ("--".projectId."-".userId."-".rolId."--"); var data = { "operation" : "useradd", "userId" : userId, "username" : username, "useremail" : useremail, "userphone" : userphone, "usermob" : usermob, "useractive" : useractive, "recuser" : 1 } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, userdeleteResult, "text"); alert ("user add a geliyor ajax bitti"); } </script> </head> <body> <form id="iletisim"> <div id="formdiv"> <table><tr> <td><span id="successfailmessage"></span></td> <tr><td><span id="userlist"></span> </td></tr> <tr><td><span id="selectedUserName"></span></td></tr> <tr><td><label for="name">User Name<input class="input" name="username" id="username" type="text" value="" /></label></td></tr> <tr><td><label for="name">Name<input class="input" name="name" id="name" type="text" value="" /></label></td></tr> <tr><td><label for="surname">Surname<input class="input" name="surname" id="surname" type="text" value="" /></label><tr> <tr><td><label for="email">Email<input class="input" name="email" id="email" type="text" value="" /></label><tr> <tr><td><label for="phone">Phone<input class="input" name="phone" id="phone" type="text" value="" /></label><tr> <tr><td><label for="phone">Mobile Phone<input class="input" name="mobphone" id="mobphone" type="text" value="" /></label><tr> <tr><td><label for="phone">Is User Active(Y/N)<input class="input" name="isuseractive" id="isuseractive" type="text" value="" /></label></td></tr> <tr><td><a href='#' onclick="javascript:usersearch();">Search User</a> </td></tr><tr> <tr><td><a href='#' id="useradd" onclick="javascript:useradd();">Add</a> </td></tr><tr> <tr><td><a href='#' id="userdelete" onclick="javascript:userdelete();">Delete</a> </td></tr><tr> <tr><td><a href='#' id="userupdate" onclick="javascript:userupdate();">Update</a> </td></tr><tr> </table> <input type="hidden" id = "userid" value="" name="userid" /> </div> </form> </body> </html> Code: [Select] hello. On my function page I have this function. function GetClub($clubs) { $qFindClub = "SELECT * FROM clubs WHERE memberID = '$clubs'"; $rFindClub = mysql_query($qFindClub); $Club = mysql_fetch_array($rFindClub); return $Club; } now when I feed it the variable $myID. If I try to echo say the club name $Clubs = GetClub($myID); echo $Clubs['name']; Nothing happens as its not working properly. Can anybody see what I have done wrong? I am still new to programming PHP and this is the first time I am creating a function. Here is where I pull the function (scroll down to commented area) <table width="250" border="0" cellpadding="2" cellspacing="0"> <tr> <td width="145"><strong>Province:</strong></td> <td colspan="2" align="right"><? echo $prov ?></td> </tr> <tr> <td><strong>Postal:</strong></td> <td colspan="2" align="right"><? echo $postal ?></td> </tr> <tr> <td><strong>Lbs:</strong></td> <td colspan="2" align="right"><? echo $lbs ?></td> </tr> <tr> <td colspan="3"> </td> </tr> </table> <img src="/images/carriers/canpar.png" border="0"/> <table width="250" border="0" cellpadding="2" cellspacing="0"> <?php if ($debugmode == 'on') { ?> <tr> <td><strong>Cost:</strong></td> <td width="14" align="right"><strong>$</strong></td> <td width="71" align="right"><? echo number_format($dzone, 2, '.', '') ?></td> </tr> <?php if ($cp_markup != "") { ?><tr> <td><strong>Markup:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? echo number_format($cp_mark, 2, '.', '') ?></td> </tr><?php } ?> <? $price = ( number_format($cp_mark, 2, '.', '') +number_format($dzone, 2, '.', '') ); } Else { ?> <tr> <td><strong>Price:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? $price = ( number_format($cp_mark, 2, '.', '') +number_format($dzone, 2, '.', '') ); echo number_format($price, 2, '.', ''); ?></td> </tr> <? } ?> <?php if ($cp_fuelcharge != "") { ?><tr> <td><strong>Fuel Charge:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? echo number_format($cp_fuelcharge, 2, '.', '') ?></td> </tr><?php } ?> <?php taxcalc(); //Here is the function pull echo $taxrow; // this is supposed to be defined in the function ?> <tr> <td class="priceresults"><strong>Total:</strong></td> <td align="right"class="priceresults"><strong>$</strong></td> <td align="right"class="priceresults"><?php $total = ( number_format($price, 2, '.', '') + number_format($tax, 2, '.', '') ); echo number_format($total, 2, '.', ''); ?></td> </tr> </table> Here is my taxcalc() function: function taxcalc() { if ($prov == "AB") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "BC") { $hst = '12%'; $hstcalc = '0.12'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "MB") { $gst = '5%'; $pst = '7%'; $gstcalc = '0.05'; $pstcalc = '0.07'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "ON") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NB") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NL") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NS") { $hst = '15%'; $hstcalc = '0.15'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NT") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NU") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "PE") { $gst = '5%'; $pst = '10%'; $gstcalc = '0.05'; $pstcalc = '0.10'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "QC") { $gst = '5%'; $pst = '7.5%'; $gstcalc = '0.05'; $pstcalc = '0.075'; $gtax = $price * $gstcalc; $ptax = ($price + $gtax) * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "SK") { $gst = '5%'; $pst = '5%'; $gstcalc = '0.05'; $pstcalc = '0.05'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "YT") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } } I am not getting any errors, just nothing is showing up. My results show up as: Code: [Select] Province: ON Postal: K2C Lbs: 25 Cost: $ 22.57 Markup: $ 0.00 Fuel Charge: $ 5.00 Total: $ 22.57 After Fuel Charge should be my taxes but they do not show up Whenever try to use the PHP mail function on my local server it also fails but then when I upload my scripts to my webspace they work fine. I think there must be something wrong with my php.ini file. Below I have copied the mail function section of my php.ini file. [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = sendmail -t -i ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = Thanks for any help. |