PHP - Problems With Sending Values From One Form To Another Page
HI,
I am trying to use pagination on the record getting displayed into the table and there's restriction on record that at a time total 15 records can be displayed and others will be displayed by clicking on NEXT (on which i did the following coding). In my SQL query 'where' clause there is select * from db where status = $query Code: [Select] <?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>?id=<?php echo $yes;?>">Next</a> <?php } // Show if not last page ?> The problem that i am facing is when i click on next then the $query gets equal to null which results to showing no record into the table kindly help how can i modify the above code so the previous value present in $query doesn't get NULL by clicking on next and show next 15 records sucessfully??? NOTE: The main purpose of the above mentioned code is to show next 15 records (which works fine if $query != NULL). Similar TutorialsHi. Me next question, is how to I send variable from one page to another page. Example: Form Page checks user inputed values, updates database then uses // Thank you Page $insertGoTo = "changepass.php"; header(sprintf("Location: %s", $insertGoTo)); to redirect users to Confirmation page. Confirmation page: Checks to make sure values where properly stored in datebase and says "YES IT WORKED" OR "NO, SOMETHING WENT WRONG" Current Code: <?php session_start(); ?> <?php $submit = $_POST['submit']; // Form Data $email = $_POST['email']; $password_old = $_POST['password_old']; $password_new = $_POST['password_new']; $password_new_con = $_POST['password_new_con']; $errorcount = 0; // Edit anything inbetween the " " for the display error message $errormsg['Email'] = "Email Entered is not in our database"; $errormsg['OldPass'] = "Old Password Entered is Incorrect. Please check your Email"; $errormsg['NewPass'] = "New Password must be between 6 and 32 characters"; $errormsg['NewPassCon'] = "New Passwords do not match."; $errormsg['SecCode'] = "Security Code is Invalid"; $errormsg['dbPass'] = "Invalide Email or activation code. Please Contact <a href='mailto:webmaster@fusionfashionhair.com?subject=Fusion Fashion Hair - Member Activation Error%20Request'>Admin</a>"; $errormsg['NoErr'] = "No Errors, Continue"; $errormsg['PlaceHold'] = ""; $errortrack[] = $errormsg['PlaceHold']; if ($_POST[submit]){ if ($errorstop = "go") { $errorstop="go"; while ($errorstop<>"stop") { //Check for security code if ($_SESSION[key]==$_POST[user_code]){ // echo "True - Continue 0"; // echo "<p>----------</p>"; $_SESSION[key]=''; } else { // echo "False - Stop 0"; $errortrack[] = $errormsg['SecCode']; $errorcount++; $errorstop="stop"; } // check for existance if (!checkEmail($email)) { // echo "False - Stop 1"; $errortrack[] = $errormsg['Email']; $errorcount++; $errorstop="stop"; } else { // echo "True - Continue 1"; // echo "<p>----------</p>"; } // check for existance if (strlen($password_old)>5) { // echo "True - Continue 2"; // echo "<p>----------</p>"; } else { // echo "False - Stop 2"; $errortrack[] = $errormsg['OldPass']; $errorcount++; $errorstop="stop"; } // check for existance if (strlen($password_new)>32||strlen($password_new)<6) { // echo "False - Stop 3"; $errortrack[] = $errormsg['NewPass']; $errorcount++; $errorstop="stop"; } else { // echo "True - Continue 3"; // echo "<p>----------</p>"; } // check for existance if ($password_new_con==$password_new) { // echo "True - Continue 4"; // echo "<p>----------</p>"; $errorstop="stop";//Get Out of loop } else { // echo "False - Stop 4"; $errortrack[] = $errormsg['NewPassCon']; $errorcount++; $errorstop="stop"; } }//End While Loop // Check database require('dbConfig.php'); // Encrypts old password to check with Database Encryped Password $password_old = md5($password_old); $check = mysql_query("SELECT * FROM {$usertable} WHERE email='$email' AND password='$password_old'"); $checknum = mysql_num_rows($check); if ($checknum==1) { // echo "True - Continue 5 Set password"; // echo "<p>----------</p>"; // Encrypts new password $password = md5($password_new); //run a query to update the account $acti = mysql_query("UPDATE {$usertable} SET password='$password' WHERE email='$email'"); } else { // echo "False - Stop 5"; $errortrack[] = $errormsg['dbPass']; $errorcount++; $errorstop="stop"; }//End if checknum // echo "True - Continue 6 GO TO HEADER PAGE"; // Thank you Page $insertGoTo = "changepass.php"; header(sprintf("Location: %s", $insertGoTo)); } else { while($errorcount>=0) { // Test display all error messages // echo "<p>----------</p>"; // echo "<p>Error Count = '$errorcount'</p>"; } die ("PLEASE FILL IN ALL FIELDS"); } } ?> <?php // LINUX PLATFORM OPTION 3 // checkEmail function checks standard email format same as preg_match() // checkEmail function checks DSN records using checkdnsrr Use list() to seperate name and domain using split function // checkdnsrr ONLY WORKS on LINUX PLATFORM // Check to see if domain and username is active // uses fsockopen() to check if its in use using port 25 function checkEmail($email) { // checks proper syntax if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)) { // gets domain name list($username,$domain)=split('@',$email); // checks for if MX records in the DNS if(!checkdnsrr($domain, 'MX')) { return false; } return true; } return false; } ?> Hello Everyone.. Im a programer in php with little experience. I have a form with 3 pages. 1st page display categories which come from category table. then user can select 1 or upto 3 category there. Then 2nd page display that selected categories and need to display relevant subject to that categories. In second page I use radio button for selected categories to keep a one category as a main category. each categories' subjects display with check boxes. In there too, user can select 1 or 3 more subject in to a particular category. In third form page, that my problem was encounter, there I need to print out selected category and their subjects in a table. first two pages are no problem for me and third form I have a problem in how to get categories and their subjects and they print as apiece in the page. like this category1 | subject1, subject2, subject3 category2 | subject1, subject2, subject3, subject and so forth. This same to my first form page Code: [Select] $q = 'SELECT * FROM category ORDER BY category_id'; $r = mysqli_query( $dbc, $q); $c = 0; $i = 0; echo '<form action="subjects.php" method="post">'; echo '<table class="form_table" ><tr>'; while($row = mysqli_fetch_array( $r, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="category[]" value="' . $row['category_id'] . '" /> ' . $row['category_name'] . '</td>'; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; ?> In second page 'subjects.php' I use Code: [Select] if ( isset($_POST['submitted1']) && isset($_POST['category']) && sizeof( $_POST['category']) == 3 ) { $_SESSION['category'] = $_POST['category']; print_r ( $_SESSION['category']); $q = 'SELECT * FROM category ORDER BY category_id'; $r = mysqli_query( $dbc, $q); while($_SESSION = mysqli_fetch_array( $r, MYSQLI_ASSOC )){ foreach( $_POST['category'] as $value ) { if ( $value == $_SESSION['category_id']) { $q = "SELECT category_subject.category_id, category_subject.subject_id, subjects FROM category_subject INNER JOIN category ON category_subject.category_id = category.category_id INNER JOIN subject ON category_subject.subject_id = subject.subject_id WHERE category_subject.category_id = {$_SESSION['category_id']}"; $r1 = mysqli_query( $dbc, $q); $c = $i = 0; echo '<table class="form_table" ><tr>'; while($_SESSION = mysqli_fetch_array( $r1, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="subject[]" value="' . $_SESSION['subject_id'] . '" /> ' . $_SESSION['subjects'] . '</td>'; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; } } } } Those two pages working properly. In third page that my problem page I tried something like this , but its not working. value come from subject.php page. Code: [Select] if ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_SESSION['subjects'])) && sizeof( $_SESSION['category']) == 1) { //$_SESSION['category'] = $_POST['category']; print_r ( $_SESSION['category']); echo 'good'; } elseif ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_POST['main_category'] ))) { print_r ( $_SESSION ); echo 'very good'; } So can any body tell me where is my mistake and help me fix this problem. any help greatly appreciated. thank you. Hey all, What I want to do is send an array of PHP values into a variable I created in Javascript. PHP code: <? $result = mysql_query("SELECT A,B FROM USS"); $num_rows = mysql_numrows($result); for($i = 0; $i < $num_rows; $i++) { $nome_utilizador = mysql_fetch_row($result); $user = $nome_utilizador[0] . " ". $nome_utilizador[1]; $teste[] = $user; } ?> Then, right after this PHP code, i have the following JS code: <script type="text/javascript"> var contacts = [ {name:"<? echo $teste[0]?>",email:"ccc@ddd.com"}, {name:"fff",email:"fff@ccc.com"}]; </script> I managed to get one value printed into the var, but what I want is to create a cycle, inside the JS code, that would get all the values from my $teste[] array, and print it into the var I created. Hope I made myself explicit Thanks, Ruben I have a form that allows a user to select from several dropdowns, employees who will receive an email message. The email script works fine, however if an employee is selected more than once (which is not a rare) then the employee will receive as many email messages as their name appears. I would like for each employee to only receive the email once. For example: I am the submitter of the form and I am also the coordinator for this particular job. Therefore, my name & email are in the array twice and I will receive two emails on submit. Here is my email script: Code: [Select] $submitter = get_employee_email($user_id); $project_manager = get_employee_email($pm_id); $accountant = get_employee_email($a_id); $coordinator = get_employee_email($pc_id); $contractor = get_employee_email($contractor_id); $director = get_employee_email($dr_id); $to = array($submitter, $project_manager, $accountant, $coordinator, $contractor, $director); foreach ($to as $t){ $headers["From"] = "TEST <TEST@gmail.com>"; $headers["To"] = $t; $headers["Subject"] = "TESTING FOR JOB ID $job_id"; $text = "TESTING. Please review!"; $html = "<html><body>TESTING. Please review!</body></html>"; $file_path = "./$file"; $crlf = "\n"; $name = "TEST.csv"; $smtp_info["host"] = "TEST@gmail.com"; $smtp_info["port"] = "40"; $mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->setHTMLBody($html); $content_type = "text/csv"; $mime->addAttachment($file_path, $content_type, $name); $body = $mime->get(); $hdrs = $mime->headers($headers); $SMTP = Mail::factory('smtp',$smtp_info); $mail = $SMTP->send($t, $hdrs, $body); } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350049.0 Hey folks, this is a demo of my cart htp://fhcs.be/cart-demo3/ I have made a send button and a mail.php , but I dont receive the mail although it says that the email is sent. Here is my mail.php <?php if($_POST['sendemail'] == 'Email') { mail('andrej13@gmail.com', 'Subject', $cart); echo 'Your mail has been sent'; } else { echo 'Your mail was not sent'; } ?> my cart.php (where the email button is) <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP Shopping Cart Demo &#0183; Cart</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to bookshop...</a></p> <form action="mail.php" method="post"> <input type="submit" name="sendemail" value="Email" /> </form> </div> </body> </html> and the functions.inc.php <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$name.'</td>'; $output[] = '<td>€'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>€'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> I am trying to extract field data from a specific row, Here is my code: $query = "SELECT * FROM music WHERE title = '%$selected%'"; $musicresult = mysql_query($query) or die ("Couldn't execute query."); $row = mysql_fetch_array($musicresult); /* extract the contents of the row */ Line 98 extract($row); echo $title." "."<BR>"; echo $select."<BR>"; /* set contents of selected to 1 */ $selectval = $select; ++$selectval ; echo $selectval."<BR>"; /* Put the data into the database */ //$query= "UPDATE music SET select=$selectval WHERE title=$selected"; //$result = mysql_query($query) or die ("could not save new data!"); Here is the error message: Warning: extract() [function.extract]: First argument should be an array in /home/content/a/c/k/acksfaq/html/theackshow/THANKYOU.PHP on line 98 The two echo statements that follow line 98 do not generate an output About the only thing that is different with is table compared with a table that this code works with is the fact that this table (music) is not indexed. What the heck am I doing wrong?? Thanks, Ack Hi I have a html form page linked to a .php page for sending me and the user the data entered in to the from: Part of the code for example purposes: HTML SIDE <form method="post" action="thankyou.php"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input name="visitormail" type="text" size="25" /> <input name="button" type="submit" id="button" value="Send" /> </form> PHP SIDE SENDING <?php $visitormail = $_POST['visitormail']; $from = "From: $visitormail\r\n"; $from = "Cc: $visitormail\r\n"; mail("forum@domain.co.uk", $subject, $message, $from); ?> What is happening is the incoming mail is coming in to me and to the user from "forum@domain.co.uk" but from my ISP domain? After lots of searching I have come up with the answer that I should be using "PHP mail() and SMTP Authentication" ? Is this the case and if so how do I set up SMTP Authentication as I am new to php!!!!! Thanks Gary i have problem : I have a page(page1) that sends details to the login page(page2) to check if the details are correct checks these and if there is a match it directs them to the next page.(page 3) The page1 sends 3 details to the page 2 that are stored into variavles but as there is no submittion when they check the details how do i then send these details onto the page 3 ? ok well my registration page is supposed to send out an email so the user can activate his or her account , but it will not send! i am using xampp for my local webhost and my php.ini settings are [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = relay.jangosmtp.net ; http://php.net/smtp-port smtp_port = 587 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = activate.social@gmail.com sendmail_path="\"C:\xampp\sendmail\sendmail.exe\"-t and my sendmail.ini is account Gmail tls on tls_certcheck off host relay.jangosmtp.net from activate.social@gmail.com auth on user activate.social@gmail.com password mypassword port 587 account default : Gmail and now here is my php script that sends the mail but it wont send , the reason i put those .ini files in here is because that is what xampp uses to send mail. here is the php script Code: [Select] <?php $to = "$email1";// which is established further up on the script which is to big! $from = 'activate.social@gmail.com'; // same email used in php.ini and sendmail.ini but wont send $subject = 'Complete Your ' . $dyn_www . ' Registration'; //Begin HTML Email Message $message = "Hi $username, Complete this step to activate your login identity at $dyn_www Click the line below to activate when ready http://$dyn_www/activation.php?id=$id&sequence=$db_password If the URL above is not an active link, please copy and paste it into your browser address bar Login after successful activation using your: E-mail Address: $email1 Password: $pass1 See you on the site!"; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text\r\n"; mail($to, $subject, $message, $headers); // supposed to send but wont ?> Hi guys, basically my problem is I have a jquery pop out window that holds a login form using the "require_once" function but when I enter my login details and send them, if there is another another form on the page e.g contact form it will send that form aswell so it will come up for the errors for the register form because they are empty. can anyone tell me how to stop this from happening? I'm curious about the mechanics of the script execution here. One page in my project sends out batch emails to all users who are registered. That part is simlple enough, but in order to do it, my page has to connect to a remote SMTP server and then submit all the recipients and messages. This process can take a little bit of time, usually 5 seconds or so. If the user hits the stop button or navigates away while my script is still executing, will it mess up the emails that are being sent? If so, what other way should I restructure my script to make it more robust? The first thing that comes to my mind is adding them to some sort of queue in the database and then have a separate script that checks periodically for messages that need to be sent and then send them. The only way to do this, though, would be to make a script designed to be called by cron, and that somewhat complicated the installation of my script which I'd like to avoid. ...to obtain an id_item users doesn´t know and I need to send to the DB
I got this
<?php require_once('Connections/conexxion.php'); ?> <?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 movimiento (venta, compra, taller, regula_mas, regula_menos, id_lente, id_cil, id_esf) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['venta'], "int"), GetSQLValueString($_POST['compra'], "int"), GetSQLValueString($_POST['taller'], "int"), GetSQLValueString($_POST['regula_mas'], "int"), GetSQLValueString($_POST['regula_menos'], "int"), GetSQLValueString($_POST['id_lente'], "int"), GetSQLValueString($_POST['id_cil'], "int"), GetSQLValueString($_POST['id_esf'], "int")); mysql_select_db($database_conexxion, $conexxion); $Result1 = mysql_query($insertSQL, $conexxion) or die(mysql_error()); } mysql_select_db($database_conexxion, $conexxion); $query_lente = "select id_lente, lente from lentes"; $lente = mysql_query($query_lente, $conexxion) or die(mysql_error()); $row_lente = mysql_fetch_assoc($lente); $totalRows_lente = mysql_num_rows($lente); mysql_select_db($database_conexxion, $conexxion); $query_esfera = "SELECT * FROM esfera"; $esfera = mysql_query($query_esfera, $conexxion) or die(mysql_error()); mysql_select_db($database_conexxion, $conexxion); $query_cilindro = "SELECT * FROM cilindro"; $cilindro = mysql_query($query_cilindro, $conexxion) or die(mysql_error()); $query_item = "select id_item from item inner join rx on rx.id_rx = item.id_rx inner join cilindro on cilindro.id_cil = rx.id_cil inner join esfera on esfera.id_esf = rx.id_esf where cilindro = ".$_POST['sel_cil']." and esfera = ".$_POST['sel_esf']." and id_lente =". $_POST['sel_lente']; $idlente = mysql_query($query_lente, $conexxion) or die (mysql_error()); ?> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Venta:</td> <td><input type="text" name="venta" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Compra:</td> <td><input type="text" name="compra" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Taller:</td> <td><input type="text" name="taller" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Regula_mas:</td> <td><input type="text" name="regula_mas" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Regula_menos:</td> <td><input type="text" name="regula_menos" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">lente:</td> <td><?php echo "<select name='sel_lente'>"; while($row= mysql_fetch_array($lente)){?> <option value=" <?php echo $row['id_lente'] ;?> " > <?php echo $row['lente']; ?> </option> <?php } ?> </select> <label for="id_lente"></label></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">cilindro:</td> <td><?php echo "<select name='sel_cil'>"; while($row= mysql_fetch_array($cilindro)){?> <option value=" <?php echo $row['id_cil'] ;?> " > <?php echo $row['cilindro']; ?> </option> <?php } ?> </select> <label for="id_cil"></label></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Esfera:</td> <td><?php echo "<select name='sel_esf'>"; while($row= mysql_fetch_array($esfera)){?> <option value=" <?php echo $row['id_esf'] ;?> " > <?php echo $row['esfera']; ?> </option> <?php } ?> </select></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">id_lente</td> <td><label for="id_lente3"></label> <input type="text" name="id_lente" id="id_lente3" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insert record" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <?php mysql_free_result($esfera); mysql_free_result($cilindro); mysql_free_result($lente); ?>and with this query $query_item = "select id_item from item inner join rx on rx.id_rx = item.id_rx inner join cilindro on cilindro.id_cil = rx.id_cil inner join esfera on esfera.id_esf = rx.id_esf where cilindro = ".$_POST['sel_cil']." and esfera = ".$_POST['sel_esf']." and id_lente =". $_POST['sel_lente']; $idlente = mysql_query($query_lente, $conexxion) or die (mysql_error());I would obtain the id_item, but , how?, because the form it´s not procesed and I´m getting no variable values. Hi i am trying to send a form to an email address but it works at my house but apparently the person i am doing this for says its not working at their home and at work. So this code works at some place. what would i be doing wrong. Here is the form: Code: [Select] <form method="post" action="envoyez.php"> Nom:<br /> <input name="Nom" type="text"><br> Courriel:<br /> <input name="Courriel" type="text"><br> Commentai <br> <textarea name="Commentaire" rows="15" cols="40"></textarea><br> <input type="submit" value="Envoyez"> </form> and here the code to send the email: Code: [Select] <?php $Nom = $_REQUEST['Nom'] ; $Courriel = $_REQUEST['Courriel'] ; $Commentaire = $_REQUEST['Commentaire'] ; mail( "do@notwork.ca", "Commentaire", $Commentaire, "From: $Courriel" ); ?> what am I doing wrong. Because If i send a comment it is working. Can anyone help pls?? Hi all I am working on a filter system that when a user selects a drop down menu item it automatically updates the page taking the value from the form and sending it through the URL parameter to update the page accordingly: <form id="category_filter" name="category_filter" method="post" action=""> <label for="category_filter"></label> <select name="category_filter" id="category_filter" style="width: 160px" onchange="this.form.submit();" > <option value="" selected class="meter-calc-text">Category</option> <?php $fetchcategories=mysql_query("SELECT * FROM `categories` ORDER BY position ASC"); while($returnedcategories=mysql_fetch_array($fetchcategories)) { echo "<option value=\"".$returnedcategories['name']."\" >".$returnedcategories['name']."</option>"; } ?> </select> </form> The only thing is, it doesn't pass the value to the url, it remains blank Many thanks for your help. Pete Hi, I had a website running a few months ago with a working contact form I am now building a new website and have copied the files changing relevant info but it is not not working it is sending me to the thank you page but the email is not coming through. Can anybody see why? <?php $EmailTo = "MYEMAIL@gmail.com"; $Subject = "Contact from Website"; $Title = Trim(stripslashes($_POST['Title'])); $FName = Trim(stripslashes($_POST['First Name'])); $LName = Trim(stripslashes($_POST['Last Name'])); $Email = Trim(stripslashes($_POST['Email'])); // prepare email body text $Body = ""; $Body .= "Title: "; $Body .= $Title; $Body .= "\n"; $Body .= "First Name: "; $Body .= $FName; $Body .= "\n"; $Body .= "Last Name: "; $Body .= $LName; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">"; } ?> Code: [Select] <form action="quoteform.php" method="post" enctype="multipart/form-data" name="quoteform" id="quoteform"> <label for="Title" id="Title">Title:</label><select name="Title"> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> <option value="Other">Other</option> </select> <label for="FName" id="FName">First Name:</label><input name="First Name" type="text" size="25"> <label for="LName" id="LName">Last Name:</label><input name="Last Name" type="text" size="25"> <label for="Email" id="Email">Email:</label><input name="Email" type="text" size="50"> <input type="submit" name="submit" value="Send" class="submit-button" title="Submit" /> <input type="button" value="Clear Message" onClick="document.forms['quoteform'].Message.value=''" /> </form> when i click submit the form isnt sending to the dataabse...any help really appreciated!! heres the code: Code: [Select] <?php session_start(); $errorMsg = ""; if (isset($_POST['billing'])){ include_once "connect_to_mysql.php"; $firstname = preg_replace("[^A-Za-z0-9]", "", $_POST['firstname']); $lastname = preg_replace("[^A-Z a-z0-9]", "", $_POST['Last Name']); $address = preg_replace("[^A-Z a-z0-9]", "", $_POST['address']); $phone = preg_replace("[^A-Z a-z0-9]", "", $_POST['phone']); $creditcard = preg_replace("[^A-Z a-z0-9]", "", $_POST['creditcard']); $expiry = preg_replace("[^A-Z a-z0-9]", "", $_POST['expiry']); $CVV = preg_replace("[^A-Z a-z0-9]", "", $_POST['CVV']); $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); if((!$firstname) || (!$lastname) || (!$address) || (!$phone) || (!$creditcard) || (!$expiry) || (!$CVV) || (!$email)){ $errorMsg = "You did not submit the following required information!<br /><br />"; if(!$firstname){ $errorMsg .= "--- First Name"; } else if(!$lastname){ $errorMsg .= "--- Last Name"; } else if(!$address){ $errorMsg .= "--- Address"; } else if(!$phone){ $errorMsg .= "--- Phone"; } else if(!$creditcard){ $errorMsg .= "--- Credit Card"; } else if(!$expiry){ $errorMsg .= "--- Expiry"; } else if(!$CVV){ $errorMsg .= "--- CVV"; } else if(!$email){ $errorMsg .= "--- Email Address"; } } else { $id = mysql_insert_id(); $sql = mysql_query("INSERT INTO customer (firstname, lastname, address, phone, creditcard, expiry, CVV, email) VALUES('$firstname','$lastname','$address','$phone','$creditcard','$expiry','$CVV','$email' now())") or die (mysql_error()); print "<br /><br /><br /><h4>OK $firstname, Thanks for Shopping:</h4><br /> We just sent a Confirmation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox. Thank You.</font></strong><br />"; exit(); } } ?> <!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>Billing</title> <link href="../dnb2.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once("../template_header2.php");?> <table width="600" align="center"> <tr> <td width="7%" align= "center">Billing</td> </tr> </table> <table width="600" align="center" cellpadding="5"> <form action="billing.php" method="post" enctype="multipart/form-data"> <tr> <td colspan="2"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> </tr> <tr> <td width="163"><div align="right">First Name:</div></td> <td width="409"><input name="firstname" type="text" value="<?php echo "$firstname"; ?>" /></td> </tr> <tr> <td width="163"><div align="right">Last Name:</div></td> <td width="409"><input name="lastname" type="text" value="<?php echo "$lastname"; ?>" /></td> </tr> <tr> <td width="163"><div align="right">Address:</div></td> <td width="409"><input name="address" type="text" value="<?php echo "$address"; ?>" /></td> </tr> <tr> <tr> <td width="163"><div align="right">Phone:</div></td> <td width="409"><input name="phone" type="text" value="<?php echo "$phone"; ?>" /></td> </tr> <tr> <td><div align="right">Credit Card: </div></td> <td><input name="creditcard" type="text" value="<?php echo "$creditcard"; ?>" /></td> </tr> <tr> <td><div align="right">Expiry: </div></td> <td> <input name="expiry" type="text" value="<?php echo "$expiry"; ?>" /> </td> </tr> <tr> <td width="163"><div align="right">CVV:</div></td> <td width="409"><input name="CVV" type="text" value="<?php echo "$CVV"; ?>" /></td> </tr> <tr> <td><div align="right">Email: </div></td> <td><input name="email" type="text" value="<?php echo "$email"; ?>" /></td> </tr> <tr> <td><div align="right"></div></td> <td><input type="submit" name="Submit" value="Submit Form" /></td> </tr> </form> </table> </body> </html> Ok I dont understand why my php form keeps sending me blank emails. Because I have a checker with java script. Did I do something wrong in my coding with the php forms or is it just the javascript on the sites problem? Here is the php form code: Code: [Select] <script language="JavaScript"> function checkForm() { var cname, caddress, cphone, cemail, ccontact; with(window.document.msgform) { cname = name; caddress = address; cphone = phone; cemail = email; ccontact = contact; } if(trim(cname.value) == '') { alert('Please enter your name'); cname.focus(); return false; } else if(trim(caddress.value) == '') { alert('Please enter your address'); cemail.focus(); return false; } else if(trim(cphone.value) == '') { alert('Please enter your phone number'); cemail.focus(); return false; } else if(!isEmail(trim(cemail.value))) { alert('Email address is not valid'); cemail.focus(); return false; } else if(trim(ccontact.value) == '') { alert('Please enter your contact person'); cemail.focus(); return false; } else { cname.value = trim(cname.value); caddress.value = trim(caddress.value); cphone.value = trim(cphone.value); cemail.value = trim(cemail.value); ccontact.value = trim(ccontact.value); return true; } } /* Strip whitespace from the beginning and end of a string Input : a string */ function trim(str) { return str.replace(/^\s+|\s+$/g,''); } /* Check if a string is in valid email format. Returns true if valid, false otherwise. */ function isEmail(str) { var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i; //regex = /^[-_.abcdefghijklmnopqrstuvwxyz0123456789]+@(([-abcdefghijklmnopqrstuvwxyz0123456789]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i; return regex.test(str); } </script> <form name="msgform" action="thankyou.php" method="post" > <table width="95%" border="0" cellspacing="1" class="tablestyle" cellpadding="1" align="center"> <tr><td>Name:</td> <td><input type="text" name="name" size="27"> </td> </tr> <tr><td>Address:</td> <td><input type="text" name="address" size="27"> </td> </tr> <tr> <td>Phone: </td> <td> <input type="text" name="phone" size="27"> </td> </tr> <tr> <td>Email: </td> <td> <input type="text" name="email" size="27"> </td> </tr> <tr> <td>Contact Person: </td> <td> <input type="text" name="contact" size="27"> </td> </tr> <tr> <td valign=top>I would like to participate at the: </td> <td valign=top> <input type="radio" name="level" value="5000">Platinum<BR> <input type="radio" name="level" value="2500">Gold<BR> <input type="radio" name="level" value="1000">Silver<br> <input type="radio" name="level" value="500">Bronze <br><br> </td> </tr> <tr> <td> <input type="radio" name="level" value="1250"option5<br> </td> </tr> <tr><td colspan="2"><input type="submit" value="submit" name="submit" onClick="return checkForm();"><input type="reset" value="Reset"></td></tr> </table></form> Here is the php process code: Code: [Select] <?php $con = mysql_connect(""); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("sponsorship", $con); //Replace with your MySQL DB Name $name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file $address=mysql_real_escape_string($_POST['address']); //This value has to be the same as in the HTML form file $phone=mysql_real_escape_string($_POST['phone']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file $contact=mysql_real_escape_string($_POST['contact']); //This value has to be the same as in the HTML form file $level=mysql_real_escape_string($_POST['level']); //This value has to be the same as in the HTML form file $sql="INSERT INTO sponsorship (name,address,phone,email,contact,level) VALUES ('$name','$address','$phone','$email','$contact','$level')"; /*form_data is the name of the MySQL table where the form data will be saved. name and email are the respective table fields*/ if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } ?> <?php $name = $_POST["name"]; $address = $_POST["address"]; $phone = $_POST["phone"]; $email = $_POST["email"]; $contact = $_POST["contact"]; $level = $_POST["level"]; echo "Name: ". $name . " <br />"; echo "Address: ". $address . " <br />"; echo "Phone: ". $phone . " <br />"; echo "Email: ". $email . " <br />"; echo "Contact: ". $contact . " <br />"; echo "Level: ". $level . " and up. <br />"; $recipient = "my email"; $subject = " subject "; $message = " '. name: .'$name '. contact: .' $contact '. address: .' $address '. phone: .' $phone '. email: .' $email '. level: .' $level "; mail($recipient, $subject, $message); ?> i keep thinking its the javascript fault but i have a navigation menu which is made from javascript and it works fine. So it leaves me to think its something i did wrong with the form or php? Can someone help me please? Thank you! hello, i have implemented a jquery function like this: http://jsbin.com/ujuse i need to grab the contents of the textarea to store it in a session, but without sending a form, is this possible?? thanks for looking |