PHP - Forms With Php Prob
this is my code
Code: [Select] <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <p> <label for="onoma">Όνομα<br /> </label> <input name="onoma" type="text" id="onoma" size="40" /> </p> <p> <label for="epitheto">Επίθετο</label> <br /> <input name="epitheto" type="text" id="epitheto" size="40" /> </p> <p> <label for="Email">Email<br /> </label> <input name="Email" type="text" id="Email" size="40" /> </p> <p> <label for="Thlefono">Τηλέφωνο</label> <br /> <input name="Thlefono" type="text" id="Thlefono" size="40" /> </p> <p>Διεύθυνση<br /> <label for="die"></label> <input name="die" type="text" id="die" size="40" /> </p> <p>Ημερομηνία που επιθειμείτε να γίνει η Κρατηση<br /> <input name="hmerominia" type="text" id="hmerominia" size="40" /> </p> <p>Ωρα στην παραπάνω ημερομηνία που επιθειμείτε <input name="wra" type="text" id="wra" size="40" /> </p> <p> <label for="Minima">Άλλο Μύνημα</label> <br /> <textarea name="Minima" id="Minima" cols="50" rows="10"></textarea> </p> <p> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <input type="hidden" name="MM_insert" value="form1" /> <br/> </form> <?php if (is_null($_POST)) { echo "<h4>Η επικύρωση της κράτησης θα γίνει απο εμάς τηλεφωνικά<br /> στο τηλέφωνο που εισάγατε. </h4> <h4>Η διαδικασία κράτησης διαρκεί 1 ημέρα</h4>"; } else{ echo "eyxaristoume kyrie"; echo $_REQUEST["onoma"]; echo " "; echo $_REQUEST["epitheto"]; echo "poy kanante kratisi sto katastima maestros" ;} ?> and this is the form action Code: [Select] <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO kratisi (onoma, epi8eto, thlefono, dieuthinsi, email, hmerominia, wra, minima) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['onoma'], "text"), GetSQLValueString($_POST['epitheto'], "text"), GetSQLValueString($_POST['Thlefono'], "text"), GetSQLValueString($_POST['die'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['hmerominia'], "text"), GetSQLValueString($_POST['wra'], "text"), GetSQLValueString($_POST['Minima'], "text")); mysql_select_db($database_maestr, $maestr); $Result1 = mysql_query($insertSQL, $maestr) or die(mysql_error()); $insertGoTo = "contact.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?>i want to make the form work like this when someone gets to that for first time to say something at the bottom and when he pushes the submit button it will say thank you i tried to do it with post if post is empty to say something and when it isnt empty to say thank you but it doesnt work where is my fault if someone can help me.. Similar TutorialsHey guys, longtime reader first time poster. i seem to be having a pagination problem and i think that some fresh eyes are in order im sure its staring in front of me.......just cant see it Code: [Select] <?php global $main; $main->query('upgraded', "SELECT `auctions`.*, `categories`.* FROM `auctions` LEFT JOIN `categories` ON `category_id` = `auction_category_id` WHERE `auction_upgrade_color` = '1' ORDER BY `auction_id` DESC LIMIT {$main->upgraded_auctions_max}"); if (!$main->auth['logged_in']) { header('Location: ' . SITE_BASE . '/login/'); } ?> <div class="left"> <? include('php/inc.featured-listings.php'); ?> </div> <div class="right"> <?php #pagination $sql = "SELECT `auction_id` FROM `auctions` WHERE `auction_user_id` = {$main->auth[user_id]}"; $q = mysql_query($sql); $page_count = ceil(mysql_num_rows($q) / $main->auctions_per_page); $current_page = (int) $_GET['current_page'] > 0 && (int) $_GET['current_page'] <= $page_count ? $_GET['current_page'] : 1; $offset = ($current_page - 1) * $main->auctions_per_page; $order = in_array($_GET['order'], array('auction_id', 'auction_views', 'auction_title', 'category_name')) ? $_GET['order'] : 'auction_id'; #listings if (!$_GET['auction_id']): $title = 'My Current Listings'; #query for newest listings $sql = "SELECT `auctions`.*, `categories`.*, `users`.* FROM `auctions` LEFT JOIN `categories` ON `category_id` = `auction_category_id` LEFT JOIN `users` ON `user_id` = `auction_user_id` WHERE `auction_user_id` = {$main->auth[user_id]} GROUP BY `$order` ORDER BY `$order` DESC LIMIT $offset, {$main->auctions_per_page}"; $q = mysql_query($sql); ?> <table cellpadding="0" cellspacing="0" class="listings" style="width: 703px;"> <tr class="header"> <td colspan="5"><h2><?php echo $title; ?></h2></td> </tr> <tr class="title"> <td width="50%" class="lborder">Listing Title</td> <td width="15%">Created In</td> <td width="15%">Created By</td> <td width="15%">Listed On</td> <td width="5%">Views</td> </tr> <?php while ($r = mysql_fetch_assoc($q)): ?> <tr class="listing<?php echo $r['auction_upgrade_color'] == '1' ? ' orange' : ''; ?>"> <td class="listing-title"><a href="/auction/<?php echo $r['auction_id']; ?>-<?php echo niceurls($r['auction_title']); ?>.html"><?php echo $r['auction_title']; ?></a></td> <td><a href="/category/<?php echo $r['category_url']; ?>/"><?php echo $r['category_name']; ?></a></td> <td><a href="/user/<?php echo $r['user_id']; ?>/"><?php echo $r['user_name']; ?></a></td> <td><?php echo howlongago($r['auction_time_listed']); ?></td> <td><?php echo number_format($r['auction_views']); ?></td> </tr> <?php endwhile; ?> </table> <div class="pagination"> <?php for ($i = 1; $i <= $page_count; $i++): ?> <a href="./?current_page=<?php echo $i; ?>"<?php echo $i == $current_page ? ' class="current"' : ''; ?>><?php echo $i; ?></a> <?php endfor; ?> </div> <?php endif; ?> </div> thanks in advance and yes i can laugh at myself hello guys, am getting prob in array_splice( ) . if i try to insert an element into an associative array, that element is converted into indexed array. <?php $capitals = array('USA' => 'Washington', 'Great Britain' => 'London', 'New Zealand' => 'Wellington', 'Australia' => 'Canberra', 'Italy' => 'Rome'); $france = array('France' => 'Paris'); array_splice($capitals, 1, 0, $france); print_r($capitals); ?> am getting output as Array ( [USA] => Washington => Paris [Great Britain] => London [New Zealand] => Wellington [Australia] => Canberra [Italy] => Rome ). pls guys help me on this...why key index is not printing as france instead of 0.. Code: [Select] $query = 'select * from ob_listings where categoryid=' . $_POST["category"] . ' and subject like '%$term%' or description like '%$term%''; i want the query to select all from the table ob_listings where categoryid=$_post["category"] AND then from the items that fit that category subject like '%$term%' or description like '%$term%'' not that familiar with sql statements please check the following code. It gave me this error Warning: Code: [Select] array_map(): The first argument, 'self::prepSessions', should be either NULL or a valid callback public function resetSess(){ if($this->isLoggedIn){ session_regenerate_id(); $this->sessions = array( 'userId' => $_SESSION['userId'], 'username' => $_SESSION['username'], 'password' => $_SESSION['password'], 'uemail' => $_SESSION['uemail'], 'userLevel' => $_SESSION['userLevel'], 'userGroup' => $_SESSION['userGroup'], 'referrer' => $_SESSION['referrer'] ); $this->userdata = array_map("self::prepSessions", $this->sessions); }else{ return false; } } public function prepSessions($sessions){ if($this->isLoggedIn){ return $sessions; } } Ok so my problem is i need to change the page link. Now if i click on the link (marked with red) it will link to the company website. So, instead of going to the website. I want to change it to link to another page which i created named (oscar.php on my index.php). But without removing the company logo on it. This is my 1st time encounter this type of case since im very new. this is the index Code: [Select] <?session_start();?> <? include ('config.php'); include ('config_email.php'); include ('config_key.php'); ?> <!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=iso-8859-1" /> <title>asia programs</title> <link rel="stylesheet" href="style.css" type="text/css" /> <script type="text/javascript" src="jquery/jquery.js"></script> <script type="text/javascript" src="jquery/thickbox/thickbox.js"></script> <link rel="stylesheet" href="jquery/thickbox/thickbox.css" type="text/css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <link rel="stylesheet" href="jquery/jquery.treeview.css" /> <script src="jquery/lib/jquery.cookie.js" type="text/javascript"></script> <script src="jquery/jquery.treeview.js" type="text/javascript"></script> <link rel="stylesheet" href="css/globalslide.css"> <style type="text/css"> #footer2 { position:absolute; bottom:0; width:100%; height:140px; background: #000; opacity:0.9; filter:alpha(opacity=92); } /* for moz/opera and others*/ html>body #footer2{position:fixed} #footer2-inner{ height: 69px; background-color: black; } /* margin-bottom ensures last content is not obscured by footer */ #content { margin-bottom: 69px; }</style> </head> <body> <? if(isset($_GET[view])) { $view = $_GET[view]; } if(isset($_GET[content])) { $content = $_GET[content]; } if(isset($_GET[ttid])) { $ttid = $_GET[ttid]; } if(isset($_GET[mod])) { $mod = $_GET[mod]; } if(isset($_GET[note])) { $note = $_GET[note]; } if ($ttid <> ''){ if ($content == 'tips') { include (VIEWPAGE.'view_event_tooltip.php'); } if ($content == 'tesm') { include (VIEWPAGE.'view_event_testimonial.php'); } if ($content == 'psevent') { include (VIEWPAGE.'view_event_ps.php'); } if ($content == 'oscar') { include (VIEWPAGE.'view_event_description.php'); } if ($content == 'prospectus') { include (VIEWPAGE.'view_event_prospectus.php'); } if ($content == 'speaker') { include (VIEWPAGE.'view_event_speakerlist.php'); } } elseif ($ttid == ''){ ?> <div id="wrapper"> <? include ("header/header.php"); ?> <div id="main-content"> <? if ($content== ''){ if ($view == ''){ include (VIEWPAGE.'home.php'); include ("counter.php"); } if ($view == 'home'){ include (VIEWPAGE.'home.php'); } if ($view == 'about'){ include (VIEWPAGE.'view_aboutus.php'); } if ($view == 'sponsorship'){ include (VIEWPAGE.'view_sponsorship.php'); } if ($view == 'gallery'){ include (VIEWPAGE.'view_gallery.php'); } if ($view == 'subgallery'){ include (VIEWPAGE.'view_subgallery.php'); } if ($view == 'news'){ include (VIEWPAGE.'view_news.php'); } if ($view == 'subnews'){ include (VIEWPAGE.'view_subnews.php'); } if ($view == 'contact'){ include (VIEWPAGE.'view_contactus.php'); } if ($view == 'enquirysubmit'){ include (VIEWPAGE.'view_enquiry_thankyou.php'); } if ($view == 'career'){ include (VIEWPAGE.'view_career.php'); } if ($view == 'event'){ include (VIEWPAGE.'view_event_search.php'); } if ($view== 'spl'){ include (VIEWPAGE.'view_event_speakernote_list.php'); } } if ($view == 'home'){ if ($content== 'list'){ include (VIEWPAGE.'home.php'); } } if ($view == 'event'){ if ($content== 'list'){ include (VIEWPAGE.'view_event_searchlist.php'); } } if ($view == 'registration') { include (VIEWPAGE.'view_event_registration.php'); } if ($view == 'regmsgsuccess') { include (VIEWPAGE.'view_event_registration_msgsuccess.php'); } if ($view == 'regmsgerror') { include (VIEWPAGE.'view_event_registration_msgerror.php'); } if ($view == 'prospectus') { include (VIEWPAGE.'view_event_prospectus.php'); } if ($view == 'msgsuccess') { include (VIEWPAGE.'view_event_prospectus_msgsuccess.php'); } if ($view == 'msgerror') { include (VIEWPAGE.'view_event_prospectus_msgerror.php'); } if ($view == 'sn') { include (VIEWPAGE.'view_event_speakernote.php'); } if ($view == 'confirmation') { if ($mod == 'reg') { include (VIEWPAGE.'view_event_registration_insert.php'); } if ($mod == 'pro') { include (VIEWPAGE.'view_event_prospectus_insert.php'); } if ($mod == 'note') { include (VIEWPAGE.'view_event_speakernote_insert.php'); } if ($mod == 'ec') { include (VIEWPAGE.'view_event_speakernote_check.php'); } if ($mod == 'ecspreg') { include (VIEWPAGE.'view_event_speakernote_ecsuccess.php'); } } ?> </div> <? include ("footer/footer.php"); ?> </div> <? if (($view == 'home')|| ($view == '')){ ?> <? } } ?> </body></html> ok so this is the code for the page that i attached a photo of it Code: [Select] <? if(isset($_GET[ttid])) { $ttid = $_GET[ttid]; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query = "select master_event.* , (DATE_FORMAT(event_datefrom, '%d %M %Y')) as datefrom, (DATE_FORMAT(event_dateto, '%d %M %Y')) as dateto, ucase(event_name) as eventname from master_event where master_event.event_id = '$ttid '"; $result=mysql_query($query); while($row = mysql_fetch_array($result)){ $eventname = $row['eventname']; $eventdesc = $row['event_desc']; $companydescription = $row['company_description']; $eventvenue = $row['event_venue']; $eventfee = $row['event_fee']; $datefrom = $row['datefrom']; $dateto = $row['dateto']; echo "<font color='#000000' face='arial' ><b> $eventname </b> </font> <br>"; echo "<font color='#000000' face='arial' ><i>Date</i> : $datefrom - $dateto <br>"; echo "<i>Venue</i> : $eventvenue <br>"; $querypstype = "SELECT DISTINCT master_pstype.pstype_id, pstype_desc FROM master_pstype INNER JOIN master_psevent ON master_psevent.pstype_id= master_pstype.pstype_id where master_psevent.event_id = '$ttid' ORDER BY pstype_id"; $resultpstype=mysql_query($querypstype); while($rowpstype = mysql_fetch_array($resultpstype)){ $pstypeid = $rowpstype['pstype_id']; $pstypedesc = $rowpstype['pstype_desc']; echo "<br><font color='#8B3A3A' size='1' face='georgia' ><b><i>$pstypedesc</i></b></font> <br>"; $queryps = "SELECT master_psevent.*, pstype_desc, company_name, company_link, company_description, logo_filename FROM master_psevent LEFT JOIN master_pstype ON master_psevent.pstype_id = master_pstype.pstype_id LEFT JOIN master_ps ON master_ps.ps_id = master_psevent.ps_id WHERE master_psevent.event_id = '$ttid' and master_pstype.pstype_id= '$pstypeid' ORDER BY pstype_desc,company_name "; $resultps=mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $companyname = $rowps['company_name']; $companylinkori = $rowps['company_link']; $companydescription = $rowps['company_description']; if ($companylinkori <> "") { $companylink = "http://".$rowps['company_link']; } else { $companylink = ""; } $logopath = $rowps['logo_filename']; if ($companylink <> ""){ echo "<font color='#4A708B' face='arial' ><a href=$companylink style=\"color:white;text-decoration: none; \" target='new'><img src=".$logo_dir."/".$logopath." width=\"15%\"></img></a>  </font>"; } else { echo "<font color='#4A708B' face='arial' ><img src=".$logo_dir."/".$logopath." width=\"15%\"></img>  </font>"; } ?> <br> <? } echo "<br>"; } } ?> Hey all, I have a CRUD php project I am working on. I have insert working reading and deleteing. The only one I have left is update. My page submits the form but when the btn is clicked my page refreshes and does not update in the db. All the controls are cleared. Im assuming I’m missing something simple or just have a small mistake that is running past me, <?php error_reporting(E_ALL & ~E_NOTICE); // include config for Database require_once "php/config.php"; // Declare the variables that will be used. $name = $language = $datenow = ""; $nameerror = $langerror = $dateerror = ""; // Process form data when its submitted if(isset($_POST["id"]) && !empty($_POST["id"])) { // Get hidden input value. $id = $_POST["id"]; $input_name = trim($_POST["name"]); if(empty($input_name)) { $nameerror = "Name is required. "; } elseif (!filter_var($input_name, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z\s]+$/")))) { $nameerror = "Please enter a valid name. "; } else { //$namesafe = mysqli_real_escape_string($connection, $input_name); $name = $input_name; } // Validate language entered $input_lang = trim($_POST["language"]); if(empty($input_lang)) { $langerror = "Please enter a language. "; } else { $language = $input_lang; } // Get current Date and Time $currentDate = date("Y-m-d H:i:s"); // OR $datetimeobj = new DateTime(); $datetimeobj->format("Y-m-d H:i:s"); //if(empty($nameerror) && empty($langerror) && empty($dateerror)) { if($name != "" && $language != "") { $sql = "UPDATE users SET name=:name, language=:language, " . "date=:date WHERE id=:id"; error_log($sql); if($stmt = $pdoConnect->prepare($sql)) { $stmt->bindParam(":name", $param_name); $stmt->bindParam(":language", $param_lang); $stmt->bindParam(":date", $param_date); $stmt->bindParam(":id", $param_id); $para_name = $name; $param_lang = $lang; $param_date = $date; $param_id = $id; if($stmt->execute()) { header("location: index.php"); exit(); } else { echo "Something went wrong, try again later."; } } } else { $errormsg = '<div > 'All fields are required to continue</div>'; } unset($stmt); unset($pdoConnect); } else { if(isset($_GET["id"]) && !empty(trim($_GET["id"]))) { $id = trim($_GET["id"]); $sql = "SELECT * FROM users WHERE id = :id"; if($stmt = $pdoConnect->prepare($sql)) { $stmt->bindParam(":id", $param_id); $param_id = $id; if($stmt->execute()) { if($stmt->rowCount() == 1) { $row = $stmt->fetch(PDO::FETCH_ASSOC); //$id = $row["id"]; $name = $row["name"]; $language = $row["language"]; $userdate = $row["date"]; } else { header("location: error.php"); exit(); } } else { echo "Something went wrong with UPDATE, try again later."; } } // Close $stmt statement unset($stmt); // Close connection unset($pdoConnect); } else { // URL doesn't contain valid 'id' parameter. header("location: error.php"); exit(); } } ?>
Hi. So I've coded many a file upload form and never had any trouble. Until now. For some reason when I try to upload MP3 files, I'll hit submit and the page just reloads. Once it does so, the file upload field is once again blank. What's odd is that images and documents upload just fine. It's only audio tracks that cause the page to reload and clear. My php.ini max file upload size is at this point set to 100M, and the files I'm trying to upload are under 10M. Any ideas? Here's the form code, just to post it-- pretty basic. I'm at a loss here.... Any ideas would be appreciated. Thanks very much. <form action="test.php" enctype="multipart/form-data" method="POST"/> <input type = "file" name = "audio" /> <p><input type ="submit" name="submit" value="do it."/><p> </form> We have this form that customers can make their own contact forms, and then it gets inserted to the database. We can show the forms with no problems, the problem lies when someone hits submit, how do I echo out the values of the form when I'm not sure what the input name or id is going to be? This sample form generated this code Code: [Select] <div class="element"> <label id="label-element-3" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Email</span> <span class="required">*</span></label> <div class="errormessage" id="errormessage-element-3"></div> <div class="option-container"> <input class="af-inputtext af-email af-formvalue " type="text" name="element-3" id="element-3" value="" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:260px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;"></div> </div> <div class="element"> <label id="label-element-4" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Textarea</span></label> <div class="errormessage" id="errormessage-element-4"></div> <div class="option-container"> <textarea class="af-textarea af-formvalue " name="element-4" id="element-4" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:300px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;" rows="6"></textarea></div> </div> <div class="element"> </div> If you notice, each input type is named "element-" with a number afterwards. So each input could be like "element-4", "element-21", and so forth. How would I post those values of the input fields when they are automatically named? Thanks in advance ok i have a questions i making a form so when users sign up to my website they we have an account page and in the account page the will have some more fields they need to filll in which i would use INSERT to put the things inside my db but what if they want to update there account should i use UPDATE I am attempting to create a login page, but my script is giving errors in relation to the forms. Involved PHP: Code: [Select] $username = mysql_real_escape_string($_POST['username']); if ($_POST['submit']=='Login') { $md5pass = md5($_POST['password']); $sql = "SELECT id,username FROM members WHERE username = '$username' AND password = '$md5pass'"; //etc etc... Involved HTML: Code: [Select] <form id="f6" action="" method="post" onsubmit="return weCheckForm(this)"> <fieldset id="e6" class="cc32"> <label id="e5" class="cc33" for="e4"> Username </label> <input id="e4" class="cc34" type="text" name="username" title="username" size="23"><br> <label id="e3" class="cc33" for="e2"> Password </label> <input id="e2" class="cc34" type="password" name="password" title="password" size="23"><br> <input id="e1" class="cc35" type="submit" title="submit" value="Login"> </fieldset> </form> Errors received: Notice: Undefined index: username in C:\(etc etc...) on line 4 Notice: Undefined index: submit in C:\(etc etc...) on line 6 Now I know that the problem is username and submit are undefined. However, I do not know how to define them in relation to the forms. Hello, I just assembly a form and for styling it I am using CSS in an external file. Problem is that IE8 and I don't know about 7 (in IE9 is ok) it doesn't show the styling inside the form... My structure is something like this: (in any other situation my css styling is displayed normally) Code: [Select] <form> <span class="myclass"> </span> </form>Is there any fix for it? Thank you I need someone that is really good with php forms, looking for major help. i need a form that is hidden until the user clicks a button on a calendar only Then the form will be visible and have a field for the day that way pressed on submit the form would go back to being invisible.
not sure how to implement this can anyone help
Hi there, I'm new to php/MySQL. Just wondering how to create a multipage form with a back, save and submit button. Also, how do you stored the form data into the datebase and how do you display a list of submitted forms by the user to the user. I am starting to build out a class to handle forms. I want to be able to add and edit data in some cases and just add data in other cases. Also want to do some ajax stuff to prevent from having to reload the pages in certain cases. I would like to view how some other form classes work so I can model mine to what I like about others but suit my needs. I was wondering if anyone has worked with any preexisting form classes that they could recommend. I know libraries like zend and so on have these built in and wasnt sure if anyone liked any one specifically and why. Hi, I have an HTML form created using Dreamweaver and now I need a script to handle the form processing. Basically what I need is for the form data received from the webpage to be organized in an email and then sent to me. I would also like to display a thank you message in the browser so the user knows it was received. I was planning to do this using CGI but a colleague suggested that CGI is old school and nowadays a developer would use PHP for this task. Is PHP the right solution for this project? The examples I have found so far always include the HTML for the form and the script needed to handle it in one file. In my case, I have an HTML form already in place and need it to work with a script to perform the email function. I know I need to set "Action=" on my webpage to point to the PHP script but what would the code look like if no HTML is needed? I hope this makes sense... Thanks for your help! Rob Hi everyone, I need a little help on making forms that automatically update as you select stuff, For example if you was to select something from a drop down menu, The page will update, And show a new drop down box that will list products compatible with the fiirst product, I could easily add these to arrays, Then the script could just pull from each array. Also I don't know if this will need any javascript... I am no good at that so please warn me if it does! Any kind of help would be highly appreciated, Thanks, Gergy. hi, I have a form in which some information is required but the username is optional however if it is left blank it says that username is taken please choose another one. how can I make it accept it if a username isn't entered? Code: [Select] <?php if (!isset($_SESSION)){ session_start(); } $fname=""; $lname=""; $username=""; $password=""; $reenterPassword=""; $address=""; $state=""; $city=""; $zip=""; $phone=""; $fax=""; $email =""; $re_enter_email =""; $payment = ""; $paypal_username=""; $ship_first_name=""; $ship_last_name=""; $ship_address=""; $ship_city=""; $ship_state=""; $ship_zip=""; $ship_email=""; $ship_re_email=""; $pet_name=""; $age=1; $breed=""; $pet_name2=""; $age2=1; $breed2=""; // Logout if(isset($_POST['logout'])){ unset($_SESSION['user']); } // Loading captcha file require_once('recaptchalib.php'); $privatekey = "6LdxwsoSAAAAAO4CWYDjkrGQsf5GXuIopJcC6SkE"; $publickey = "6LdxwsoSAAAAAFrZTLjBoDvLLjk9_NR_ubncL-24"; require_once("functions.php"); DatabaseConnection(); $state = $_POST['state']; $payment = $_POST['payment_Method']; $breed = $_POST['breed']; $ship_state=$_POST['Shipstate']; if((isset($_REQUEST["submit"]) && $_REQUEST["submit"]=="Log in") || $_SESSION['user']){ if(!$_SESSION['user']){ $login_username = isset($_REQUEST["username"])?$_REQUEST["username"]:""; $login_password = isset($_REQUEST["password"])?$_REQUEST["password"]:""; $msg = array(); if ($login_username == "") $login_msg['username_empty'] = "Please enter your name"; if ($login_password == "") $login_msg['password_empty'] = "Please enter your password"; $query = "SELECT * FROM customers WHERE username = '$login_username' AND password = '".$login_password."'"; }else{ $customer_id = $_SESSION['user']; $query = "SELECT * FROM customers WHERE customer_id='$customer_id'"; } if (!$login_msg){ $login_process = true; $result = mysql_query($query) or die("Database error: " . mysql_error()); if (mysql_num_rows($result) > 0){ $row = mysql_fetch_object($result); $customer_id = $row->customer_id; $_SESSION['user'] = $customer_id; $fname = $row->fname; $lname = $row->lname; $username=$row->username; $address=$row->address; $state=$row->state; $city=$row->city; $zip=$row->zip; $phone=$row->phone; $fax=$row->fax; $email =$row->email; $payment = $row->payment_method; $paypal_username=$row->paypal_username; $ship_first_name=$row->ship_first_name; $ship_last_name=$row->ship_last_name; $ship_address=$row->ship_address; $ship_city=$row->ship_city; $ship_state=$row->ship_state; $ship_zip=$row->ship_zip; $ship_email=$row->ship_email; $pet_name=$row->pet_name; $age=$row->age; $age_month=$row->age_month; $breed=$row->breed; $pet_name2=$row->pet_name2; $age2=$row->age2; $age_month2=$row->age_month2; $breed2=$row->breed2; }else{ $login_msg['login_fail'] = "Username, password combination is not valid."; } } } if(isset($_REQUEST["submit"]) && $_REQUEST["submit"]=="submit"){ $msg=array(); $fname=isset($_REQUEST["fname"])?$_REQUEST["fname"]:""; $lname=isset($_REQUEST["lname"])?$_REQUEST["lname"]:""; $username=isset($_REQUEST["lname"])?$_REQUEST["username"]:""; $password=isset($_REQUEST["lname"])?$_REQUEST["password"]:""; $reenterPassword=isset($_REQUEST["lname"])?$_REQUEST["reenterPassword"]:""; $address=isset($_REQUEST["address"])?$_REQUEST["address"]:""; $state=isset($_REQUEST["state"])?$_REQUEST["state"]:""; $city=isset($_REQUEST["city"])?$_REQUEST["city"]:""; $zip=isset($_REQUEST["zipcode"])?$_REQUEST["zipcode"]:""; $phone=isset($_REQUEST["phone"])?$_REQUEST["phone"]:""; $fax=isset($_REQUEST["fax"])?$_REQUEST["fax"]:""; $email =isset($_REQUEST["email"])?$_REQUEST["email"]:""; $re_enter_email =isset($_REQUEST["re_email"])?$_REQUEST["re_email"]:""; $re_enter_email= $email; $payment = isset($_POST['payment_Method'])?$_POST['payment_Method']:""; $paypal_username=isset($_REQUEST["PayPal_username"])?$_REQUEST["PayPal_username"]:""; $ship_first_name=isset($_REQUEST["Shipfname"])?$_REQUEST["Shipfname"]:""; $ship_last_name=isset($_REQUEST["Shiplname"])?$_REQUEST["Shiplname"]:""; $ship_address=isset($_REQUEST["Shipaddress"])?$_REQUEST["Shipaddress"]:""; $ship_city=isset($_REQUEST["Shipcity"])?$_REQUEST["Shipcity"]:""; $ship_state=isset($_REQUEST["Shipstate"])?$_REQUEST["Shipstate"]:""; $ship_zip=isset($_REQUEST["Shipzipcode"])?$_REQUEST["Shipzipcode"]:""; $ship_email=isset($_REQUEST["Shipemail"])?$_REQUEST["Shipemail"]:""; $ship_re_email=$ship_email; $pet_name=isset($_REQUEST["petName"])?$_REQUEST["petName"]:""; $age=isset($_REQUEST["age"])?$_REQUEST["age"]:''; $age=isset($_REQUEST["age_month"])?$_REQUEST["age_month"]:1; $breed=isset($_REQUEST["breed"])?$_REQUEST["breed"]:""; $nutritional_needs=isset($_REQUEST["nutritionalNeeds"])?$_REQUEST["nutritionalNeeds"]:""; $special_instructions=isset($_REQUEST["specialInstructions"])?$_REQUEST["specialInstructions"]:""; $pet_name2=isset($_REQUEST["petName2"])?$_REQUEST["petName2"]:""; $age2=isset($_REQUEST["age2"])?$_REQUEST["age2"]:""; $age2=isset($_REQUEST["age_month2"])?$_REQUEST["age_month2"]:1; $breed2=isset($_REQUEST["breed2"])?$_REQUEST["breed2"]:""; $nutritional_needs2=isset($_REQUEST["nutritionalNeeds2"])?$_REQUEST["nutritionalNeeds2"]:""; $special_instructions2=isset($_REQUEST["specialInstructions2"])?$_REQUEST["specialInstructions2"]:""; // Products information $product_name=isset($_REQUEST["productname"])?$_REQUEST["productname"]:""; $quantity=isset($_REQUEST["quantity"])?$_REQUEST["quantity"]:0; $price=isset($_REQUEST["price"])?$_REQUEST["price"]:0; $quantity_diff=isset($_REQUEST["quantity_diff"])?$_REQUEST["quantity_diff"]:0; $price_diff=isset($_REQUEST["price_diff"])?$_REQUEST["price_diff"]:0; $sales_tax=isset($_REQUEST["salestax"])?$_REQUEST["salestax"]:0; $subtotal=isset($_REQUEST["subtotal"])?$_REQUEST["subtotal"]:0; $shipping_cost=isset($_REQUEST["shippingcost"])?$_REQUEST["shippingcost"]:0; $total=isset($_REQUEST["total"])?$_REQUEST["total"]:0; // check for login if(isset($_POST['customer_id'])){ $customer_id = $_POST['customer_id']; $query = "SELECT * FROM customers WHERE customer_id='$customer_id'"; $result = mysql_query($query) or die("Database error: " . mysql_error()); if (mysql_num_rows($result) > 0){ $login_process = true; $_SESSION['user'] = $customer_id; $row = mysql_fetch_object($result); $fname = $row->fname; $lname = $row->lname; $username=$row->username; } } // Is username taken ? if(!$login_process){ $query = "SELECT * FROM customers WHERE username = '$username'"; $result = mysql_query($query) or die("Database error: " . mysql_error()); if (mysql_num_rows($result) > 0){ array_push($msg,"This username is already taken, please choose another one."); } } if($fname==""){ array_push($msg,"Please Enter First Name."); } if($lname==""){ array_push($msg,"Please Enter Last Name."); } /* if($username==""){ array_push($msg,"Please Enter User Name."); } if(!$login_process){ if($password==""){ array_push($msg,"Please Enter Password."); } if($reenterPassword==""){ array_push($msg,"Please Enter Re-Enter Password."); } if($reenterPassword!=$password){ array_push($msg,"Both passwords does not match."); } }*/ if($address==""){ array_push($msg,"Please Enter Address."); } if($city==""){ array_push($msg,"Please Enter City."); } if($state=="Please choose a state"){ array_push($msg,"Please Select State."); } if($zip==""){ array_push($msg,"Please Enter Zip."); } else { if(!is_numeric($zip)){ array_push($msg,"Please Enter Digits In Zip."); } } if($phone==""){ array_push($msg,"Please Enter Phone."); } else { if(!is_numeric($phone)){ array_push($msg,"Please Enter Digits In Phone."); } } if($email==""){ array_push($msg,"Please Enter Email."); } if($payment==""){ //array_push($msg,"Please Select Payment Method."); } if($paypal_username==""){ // array_push($msg,"Please Enter Paypal User Name."); } if($ship_first_name==""){ array_push($msg,"Please Enter Shipping First Name."); } if($ship_last_name==""){ array_push($msg,"Please Enter Shipping Last Name."); } if($ship_address==""){ array_push($msg,"Please Enter Shipping Address."); } if($ship_city==""){ array_push($msg,"Please Enter Shipping City."); } if($ship_state==""){ array_push($msg,"Please Select Shipping State."); } if($ship_zip==""){ array_push($msg,"Please Enter Shipping Zip."); } else { if(!is_numeric($ship_zip)){ array_push($msg,"Please Enter Digits In Shipping Zip."); } } if($ship_email==""){ // array_push($msg,"Please Enter Shipping Email."); } // Check Captcha $resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]); if (!$resp->is_valid) { array_push($msg,"Wrong Captcha, please try again."); } // Insert customer if($login_process){ $sql0 = "UPDATE customers SET address='$address',city='$city', state='$state', zip='$zip', phone='$phone', fax='$fax', email='$email', re_enter_email='$re_enter_email', ship_first_name='$ship_first_name', ship_last_name='$ship_last_name', ship_address='$ship_address', ship_city='$ship_city', ship_state='$ship_state', ship_zip='$ship_zip', ship_email='$ship_email', ship_re_enter_email='$ship_re_email', pet_name='$pet_name', age='$age', breed='$breed', pet_name2='$pet_name2', age2='$age2', breed2='$breed2', age_month='$age_month', age_month2='$age_month2' WHERE customer_id='$customer_id'"; if(count($msg) == 0){ $r= mysql_query($sql0) or die("Query Error : " . mysql_error()); $customer = $customer_id; } }else{ $sql0="INSERT INTO customers (fname, lname,username,password, address, city, state, zip, phone, fax, email, re_enter_email, ship_first_name, ship_last_name, ship_address, ship_city, ship_state, ship_zip, ship_email, ship_re_enter_email , pet_name, age, breed, pet_name2, age2, breed2, age_month, age_month2) VALUES ('$fname', '$lname','$username','$password', '$address', '$city', '$state', '$zip', '$phone', '$fax', '$email', '$re_enter_email', '$ship_first_name', '$ship_last_name', '$ship_address', '$ship_city', '$ship_state', '$ship_zip', '$ship_email', '$ship_re_email', '$pet_name', '$age', '$breed', '$pet_name2', '$age2', '$breed2', '$age_month', '$age_month2')"; if(count($msg) == 0){ $r= mysql_query($sql0) or die("Query Error : " . mysql_error()); $customer = mysql_insert_id(); } } // Insert Order $sql1="INSERT INTO orders (product_name, customer, quantity, price, sales_tax, subtotal, shipping_cost, total, nutritional_needs, special_instructions, nutritional_needs2, special_instructions2) VALUES ('$product_name', '$customer', '$quantity_diff', '$price_diff', '$sales_tax', '$subtotal', '$shipping_cost', '$total', '$nutritional_needs', '$special_instructions', '$nutritional_needs2', '$special_instructions2')"; if(count($msg) == 0){ $m= mysql_query($sql1) or die("Query Error : " . mysql_error()); } } ?> Hi, I have found myself in a bit of a cul-de-sac. Hope you can help as it is driving me crazy. The scenario: I have an html form (_post) which I would like to write the contents of to a one XML file using php. The problem is: The html page has three/four forms in it. Form a = (submit a writes/updates only to section a) Form b = (submit b writes/updates only to section b) Form c = (submit c writes/updates only to section c) Form d= (submit a, b, c writes/updates all sections) The XML page has three sections a, b & c To conclude, I want to be able to update the XML file in sections or update them all as a whole. How can I go about achieving this? Thanks Info: When Customer clicks the "Add More Stuff" button on "/merchandise.php" to add more stuff, modify quantities, etc., the page submits to itself. Desired: I want a "FINISHED" button on the bottom of the page. When clicked on, Customer lands on a Thank You, "/FINISHED.php" page. Problem: The <form action="FINISHED.php"....> does not have access to the variables in the first form <form action="$_SERVER['PHP_SELF']">. Question: Using Sessions, javascript, or fancy PHP, is there a way the 2nd form can capture all the data from the first form, so when Customer clicks the FINISHED button, all the variables are sent to the FINISHED.php page?
Like: Reasons: There are too many PHP and Javascript variables created in the first form, many of which I don't understand, it would take me the rest of year 2019 to go line by line and rewrite all of the code. Requisite whining: Some code is beyond my skill level. For example, when the customer increases a quantity from "1" to "2" javascript will instantly change the displayed dollar-amount from $1.00 to $2.00 without actually "submitting/refreshing" the entire page. Though the displayed amount changes visually, the PHP $variable remains what it was until the page submits to itself. That means I cannot use $_SESSION to capture the newly-displayed amount until the page resubmits to itself. I've tried everything I can think of.... the closest solution I've found is the new HTML5 "formaction" tag, but I'm looking for a more universal solution (doesn't work in all browsers). Thank you!!
Edited February 28, 2019 by StevenOliver |