PHP - I'm Facing Database Submission Issues
I'm facing database submission issues, please can someone with a good heart help me. Below is my code I don't know what I did wrong it won't submit mydata to the database it gives me error. Notice: Undefined variable: error in /home/psdelive/public_html/admin/add package.php on line 118
<?php session_start();
$activity = $_POST['activity'];
{
<p style="line-height:40px;">Error in posting</p>
}
$sele = "SELECT * from details";
?> <title>Add Package</title> <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.css" /> <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.min.css" /> <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.css" /> <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" /> <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.js"></script> <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/npm.js"></script>
<style> <body> <div class="container-fluid" style="background:green; height:70px;"> </div>
<div class="row" style=" min-height:80px;"> <div class="col-lg-2" style="background:gray; height:1100px;">
<a class="btn btn-success" style="width:100%; margin-top:20px;" href="add user">Add Users</a> <a class="btn btn-success" style="width:100%; margin-top:20px;" href="add package">Add Packages</a> <a class="btn btn-success" style="width:100%; margin-top:20px;" href="all packages">View Packages</a> <a class="btn btn-success" style="width:100%; margin-top:20px;" href="send">Send Mail</a> <a class="btn btn-success" style="width:100%; margin-top:20px;" href="logout">Logout</a> </div>
echo $error;
?> <option><?php echo $row['track_code']; ?></option>
<?php </div>
<div class="form-group">
</form>
</html> Similar TutorialsHi, I have a form with a textarea the problem I am facing is the user is logged in and is on a page http://localhost/page/profile.php?id=28 now what I want to do is after the data is inserted I want them to be re directed back to http://localhost/page/profile.php?id=28 the same url. I tried a few things with header also tried making the form action $_SERVER['PHP_SELF'] but what happens with $_SERVER['PHP_SELF'] for some odd reason the page doesnt Reload untill I refresh the browser tried in a few browsers same result. Could some one help me with this much appreciated! Hello everyone, I am trying triple drop down menu first and second menus are working but third one is not working and also the data is not being displayed on the webpage even though I have used "echo" command.. I am unsure what is the problem and how to correct it. So I am attaching my code in this email, could you please look into it and help me with it. I have 1st drop menu for State : Tennessee Alabama Georgia 2nd Drop down list for County: Anderson Bredford Benton 3rd Drop down list for Genus Acer Aristida Eg: Tennnesse -> Anderson, Bredford, Benton and Anderson -> Acer, Aristida and when I select Tennesse->Anderson->Acer it has to display all the information of the table based on these selected values. Could you please help me with this. This is my link for the complete code http://pastebin.com/vvLrpCcr The execution link is http://sozog.utc.edu/~tdv131/MYSQL/genus1c.htm Hey all, First off, if this is in the wrong section I apologize. I wasn't sure if it should be here or the mySQL section. What's going on is, I'm in the process of learning the Prepared Statement way of doing things and am changing / updating my code to reflect the changes. Everything was going fine until I attempted to do what I could do using old MySQL methods and that is display the queried results on the same page. I can place a query and display the results as they should be displayed if I only use one block of code. However, if I try to do any additional queries on the same page, they get killed and do not display anything even though I know the query is fine because I can test the exact same syntax below one a different page and it works. Here's a code snippet for an example: Code: [Select] Code: <table> <tr> <td> // The below code will display a selection box containing various strings such as "hello world", "great to be here", "Wowserz", "this is mind blowing" etc. that are stored in the database. <?php echo "<select = \"SpecialConditions\">"; if($stmt->num_rows == NULL){ echo "No results found."; }else{ while($stmt->fetch()){ echo "<option value=\"$specialId\">$specialcondition</option>"; } } echo "</select>"; ?> </td> <td> // If I place another fetch query below the above fetch() query, this one will not show up. This one is supposed to display values 1 - 20 that have been stored in the DB. <?php echo "<select = \"NumberSets\">"; if($stmt->num_rows == NULL){ echo "No results found."; }else{ while($stmt->fetch()){ echo "<option value=\"".$numbers."\">".$numbers."</option>"; } } echo "</select>"; ?> </td> </tr> </table> What am I doing wrong with this? When I use regular SQL queries I can display multiple results on the same page. The results are being pulled from two separate joined tables but I don't think that's the issue. hey guys, I'm getting a problem uploading my csv file to mysql database, the code on the top half just makes sure that I don't import data that I don't want into the database, numbers that are too high or too low on certain rows, and the second half is importing the array that I create from the csv file into the database however I'm getting the following error
Duplicate entry 'Array' for key 'strProductCode'
Now I've never had this error before and I'm not sure what's causing it so any help would be very much appreciated
$data = array(); if (($handle = fopen("stock.csv", "r")) !== FALSE) { while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { // only add rows to the array where the 4th column value is greater than or equal to 10 if(($row[3] >= 10 && $row[4] >= 5) OR ($row[3] >= 0 AND $row[4] > 5)){ if($row[4] < 1000){ $data[] = $row; } } } foreach ($data as &$value) { mysql_query("INSERT INTO tblProductData (intProductDataId, strProductCode, strProductName, strProductDesc, strProductStock, strProductCost, dtmDiscontinued, dtmAdded, stmTimestamp) VALUES(null, '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', 'time', 'added', 'time') ") or die(mysql_error()); } } I'm trying to figure out where my problem is. Its not submitting my form. I'm getting the alert but when it submits it does the url?variables=whatever deal. Code: [Select] <?php require ('php/eventnames.php'); ?> <script type="text/javascript" src="forms/addnew/js/eventnames.js"></script> <!-- Form --> <form action="#" id="eventNameForm" > <fieldset> <legend>Add New Event Name</legend> <div class="field required"> <label for="eventName">Event Name</label> <input type="text" class="text" name="eventName" id="eventName" title="Event Name"/> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <div class="field required"> <label for="shortName">Event Short Name</label> <input type="text" class="text" name="shortName" id="shortName" title="Event Short Name"/> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <div class="field required"> <label for="eventType">Event Type</label> <select class="dropdown" name="eventType" id="eventType" title="Event Type"> <option value="">- Select -</option> <?php $eventTypes = array('Singular', 'Recurring', 'Pay Per View'); foreach($eventTypes as $et): ?> <option value="<?php echo $et; ?>"><?php echo $et; ?></option> <?php endforeach; ?> </select> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <input type="hidden" name="userID" id="userID" value="<?php echo $userID; ?>" /> <input type="submit" class="submit" name="submitEventName" id="submitEventName" title="Submit Event Name" value="Submit Event Name"/> </fieldset> </form> <!-- /Form --> <!-- Messages --> <div class="message message-error"> <h6>Required field missing</h6> <p>Please fill in all required fields. </p> </div> <div class="message message-success"> <h6>Operation succesful</h6> <p>Content Page was added to the database.</p> </div> Code: [Select] $(document).ready(function() { $('div.message-error').hide(); $('div.message-success').hide(); alert("Test Alert!"); ("#eventNameForm").validate({ rules: { eventName: { required: true }, shortName: { required: true }, eventType: { required: true, rangelength: [1] } }, messages: { eventName: "Please enter the event name!", shortName: "Please enter the event's short name!", eventType: "Please enter the event type!" }, submitHandler: function(form) { var userID = $("input#userID").val(); var eventName = $("input#eventName").val(); var shortName = $("input#shortName").val(); var eventType = $("select#eventType").val(); var dataString = 'userID=' + userID + '&eventName=' + eventName + '&shortName=' + shortName + '&eventType=' + eventType + '&submitEventName=True'; $.ajax({ type: "POST", url: "processes/eventnames.php", data: dataString, success: function(myNewVar) { if (myNewVar == 'good') { $('div.message-error').hide(); $("div.message-success").html("<h6>Operation successful</h6><p>" + eventName + " Page saved successfully.</p>"); $("div.message-success").show().delay(10000).hide("slow"); $(':input','#eventNameForm') .not(':submit, :hidden') .val(''); } else if (myNewVar == 'bad1') { $('div.message-success').hide(); $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + eventName + " already exists in the database.</p>"); $("div.message-error").show(); } else if (myNewVar == 'bad2') { $('div.message-success').hide(); $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + shortName + " already exists in the database.</p>"); $("div.message-error").show(); } else if (myNewVar == 'bad3') { $('div.message-success').hide(); $("div.message-error").html("<h6>Operation unsuccessful</h6><p>" + eventName + " and " + shortName + " already exists in the database.</p>"); $("div.message-error").show(); } } }); return false; } }); }); Where should my Form go once it is submitted? I am reading through some old code, and I was using some pretty convoluted programming to get everything (e.g. error and success messages after form submittal) to work. Basically what I would do was... Code: [Select] HTML to Open Page PHP to Handle Form If Data Okay... Success Message (e.g. "Your account was created!") HTML to close out Page If Data Invalid... Failure Message (e.g. "A System Error occurred. Please contact the Administrator.") HTML to close out Page HTML Form HTML to Close Page I have heard that you should always put your PHP first in the script and then follow it up with your HTML Page and Form. But where should you go once the form is submitted? My second attempt at things - to fix the mess above - was to REDIRECT the user to a "Handling Page" which basically was a large case statement that would read a "processing code" and display the right message. But that seems kind of hokey too?! Can someone help me come up with a more professional and scalable solution?? Thanks, Debbie Hello, I like to send and reading variable with post and get. Is it possible? I have do that but that doesn't work Code: [Select] <form id="test" action="test.php" method="post"> <input type="hidden" name="a_recup" value="variable_ici"/> </form> <a href='test.php?town=Montreal' onclick='document.getElementById("test").submit()'>link</a> <a href='test.php?town=New_York' onclick='document.getElementById("test").submit()'>Link1</a> <?php $variable=$_POST['a_recup']; echo $variable; $ville=$_GET['town']; echo $town; ?> Thanks for your help Hello there, I have made a ban form on my website. It is all going good until I open phpmyadmin. There is two records from one submission. Usually the second record has some missing information. There should not be a duplicate and I do not understand why it is happening. If anybody could explain what is causing this would be great. Here is the page. <?php session_start(); require_once 'database.php'; if(isset($_SESSION['mod'])) { $userid = $_SESSION['user']; if(isset($_GET['action']) && strcasecmp($_GET['action'], "file") == 0) // checks to see if form is submitted { $username = $_POST['user']; $time = $_POST['time']; $reason = $_POST['reason']; $u_time = date("U"); $r_time = date("m-j-Y g:i A"); if($time == "00") { // if the time is a permaban $sql=mysql_query("SELECT * FROM user WHERE username='$username'") or die("Error 1"); $data=mysql_query($sql); $user_ip = $data['last_ip']; if ($user_ip != 127.0.01) { // admin stuff ;) $p_ban=mysql_query("INSERT INTO ip_ban (ip,real_time,unix_time,days_left,reason) VALUES ('$user_ip','$r_time','$u_time','99999999999','$reason')") or die("Error 2"); echo 'The user '.$username.' has been banned.'; }else{ // if it is an admin echo 'You cannot ban that user.'; } }else{ // not a perma ban if($username != "admin") // admin stuff { $temp_ban=mysql_query("INSERT INTO blacklist (email,reason,end_date,appeal,unixtime) VALUES ('$username','$reason','$time','No','$u_time')") or die("Error 3"); echo 'The user '.$username.' has been banned.'; }else{ echo 'You cannot ban that user.'; } } }else{ $user_ban = $_GET['user']; if(isset($user_ban)) { ?> <form name="file_ban" method="post" action="?action=file"> Username: <input type="text" name="user" value="<?php echo $user_ban; ?>"><br /> Length of Ban: <select name="time"> <option value="1">1 Day</option> <option value="3">3 Days</option> <option value="5">5 Day</option> <option value="7">1 Week</option> <option value="15">15 Days</option> <option value="30">1 Month</option> <option value="90">3 Months</option> <option value="99999999999">∞ Infinity (Permaban)</option> <option value="00">IP Ban (Does not expire)</option> </select><br /> Reason: <br /> <textarea name="reason" cols="50" row="4"></textarea><br /> <input type="submit" value="Ban"> <?php }else{ } } }else{ // If session is not set header("Location: index.php"); } ?> If you need any explanation of what anything does, just please ask. Thank you!
Hi All, ## First Document if(!empty($_FILES["dc1"])){ $fileName1 = htmlspecialchars_decode((basename($_FILES["dc1"]["name"]))); $fileTypeA1 = pathinfo($fileName1, PATHINFO_EXTENSION); $targetFilePath1 = $uploadDir . $uID . '-' . $randnum . '.' .$fileTypeA1; if(move_uploaded_file($_FILES["dc1"]["tmp_name"], $targetFilePath1)){ $uploadedFile1 = $targetFilePath1; } } ## Second Document if(!empty($_FILES["dc2"])){ $fileName2 = htmlspecialchars_decode((basename($_FILES["dc2"]["name"]))); $fileTypeA2 = pathinfo($fileName2, PATHINFO_EXTENSION); $targetFilePath2 = $uploadDir . $uID . '-' . $randnum . '.' .$fileTypeA2; if(move_uploaded_file($_FILES["dc2"]["tmp_name"], $targetFilePath2)){ $uploadedFile2 = $targetFilePath2; } } Edited October 13, 2020 by SH1989 Clean code up Hi guys, I got this form so a user can submit a care guide for different species of animal. However the script runs, but the query to SET the species information does not run and the success message is not displayed. Here is what I have got
<?php session_start(); error_reporting(E_ALL); ini_set('display_errors', '1'); require( 'database.php' ); include('includes/overall/header.php'); $username = $_SESSION['loggedinuser']; if (isset($_POST['username'], $_POST['email'], $_POST['fishtype'], $_POST['speciesCommon'], $_POST['speciesScientific'], $_POST['speciesSynonym'], $_POST['origin'], $_POST['size'], $_POST['environment'], $_POST['waterChemistry'], $_POST['temperature'], $_POST['temperature1'], $_POST['feeding'], $_POST['sexing'], $_POST['compatability'], $_POST['temperament'], $_POST['breeding'], $_POST['comments'], $_POST['reward'], $_POST['username'], $_POST['email'] ) ) { if( $_POST['fishtype'] == "" ) { include('includes/overall/header.php'); echo "You must select a species type"; include('includes/overall/footer.php'); } elseif( $_POST['speciesCommon'] == "" ) { include('includes/overall/header.php'); echo "You must select a species type"; include('includes/overall/footer.php'); } elseif( $_POST['speciesScientific'] == "" ) { include('includes/overall/header.php'); echo "You must select a scientific name"; include('includes/overall/footer.php'); } elseif( $_POST['speciesSynonym'] == "" ) { include('includes/overall/header.php'); echo "You must select a species synonym"; include('includes/overall/footer.php'); } elseif( $_POST['origin'] == "" ) { include('includes/overall/header.php'); echo "You must select the origin of this species"; include('includes/overall/footer.php'); } elseif( $_POST['size'] == "" ) { include('includes/overall/header.php'); echo "You must select a average size"; include('includes/overall/footer.php'); } elseif( $_POST['environment'] == "" ) { include('includes/overall/header.php'); echo "You must select the type of environment suited to this species"; include('includes/overall/footer.php'); } elseif( $_POST['waterChemistry'] == "" ) { include('includes/overall/header.php'); echo "You must select the typeif water chemistry required for this species"; include('includes/overall/footer.php'); } elseif( $_POST['temperature'] == "" ) { include('includes/overall/header.php'); echo "You must select a minimum temperature for this species"; include('includes/overall/footer.php'); } elseif( $_POST['temperature1'] == "" ) { include('includes/overall/header.php'); echo "You must select a maximum temperature for this species"; include('includes/overall/footer.php'); } elseif( $_POST['feeding'] == "" ) { include('includes/overall/header.php'); echo "You must enter feeding information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['sexing'] == "" ) { include('includes/overall/header.php'); echo "You must enter sexing information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['compatibility'] == "" ) { include('includes/overall/header.php'); echo "You must enter compatibility information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['temperament'] == "" ) { include('includes/overall/header.php'); echo "You must enter temperament information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['breeding'] == "" ) { include('includes/overall/header.php'); echo "You must enter breeding information for this species"; include('includes/overall/footer.php'); } elseif( $_POST['comments'] == "" ) { include('includes/overall/header.php'); echo "You must enter comments for this species"; include('includes/overall/footer.php'); } elseif( $_POST['compatibility'] == "" ) { include('includes/overall/header.php'); echo "You must select your reward"; include('includes/overall/footer.php'); } else { require( 'database.php' ); $fishtype = mysqli_real_escape_string($con, $_POST['fishtype']); $speciesCommon = mysqli_real_escape_string($con, $_POST['speciesCommon']); $speciesScientific = mysqli_real_escape_string($con, $_POST['speciesScientific']); $speciesSynonym = mysqli_real_escape_string($con, $_POST['speciesSynonym'] ); $origin = mysqli_real_escape_string($con, $_POST['origin']); $size = mysqli_real_escape_string($con, $_POST['size']); $environment = mysqli_real_escape_string($con, $_POST['environment']); $waterChemistry = mysqli_real_escape_string($con, $_POST['waterChemistry']); $temperature = mysqli_real_escape_string($con, $_POST['temperature']); $temperature1 = mysqli_real_escape_string($con, $_POST['temperature1']); $feeding = mysqli_real_escape_string($con, $_POST['feeding']); $sexing = mysqli_real_escape_string($con, $_POST['sexing']); $compatibility = mysqli_real_escape_string($con, $_POST['compatibility']); $temperament = mysqli_real_escape_string($con, $_POST['temperament']); $breeding = mysqli_real_escape_string($con, $_POST['breeding']); $comments = mysqli_real_escape_string($con, $_POST['comments']); $reward = mysqli_real_escape_string($con, $_POST['reward']); $username = mysqli_real_escape_string($con, $_POST['username']); $email = mysqli_real_escape_string($con, $_POST['email']); // Define a query to run $regCareGuide = "INSERT INTO species( fishtype, speciesCommon, speciesScientific, speciesSynonym, origin, size, environment, waterChemistry, temperature, temperature1, feeding, sexing, compatibility, temperament, breeding, comments ) VALUES ( '". $fishtype ."', '". $speciesCommon ."', '". $speciesScientific ."', '". $speciesSynonym ."', '". $origin ."', '". $size ."', '". $environment ."', '". $waterChemistry ."', '". $temperature ."', '". $temperature1 ."', '". $feeding ."', '". $sexing ."', '". $compatability ."', '". $temperament ."', '". $breeding ."', '". $comments ."', '". $reward."' ) WHERE `username` = '$username' AND `email` = '$email'"; // Query the database $result = mysqli_query($con, $regCareGuide); // Check if the query failed if( !$result ) { die('There was a problem executing the query ('.$regCareGuide.'):<br>('.mysqli_errno($con).') '.mysqli_error($con)); } else { echo 'Your care guide has been submitted and your account has been credited.'; } } } include('includes/overall/footer.php'); // Close the connection mysqli_close($con); ?>This is pretty much the same as my changepassword.php page but the query is different and this seems to have prevented the script from running correctly. I have tried different variations on INSERT to add the data to the database but nothing is working, Also an online PHP checker says there is no error in the code. Please help! Hey, I have a submission form to ask for support to my support email. But when i recieve messages the break lines are not counted for and i get the r/n. I then added the nl2br($Message) but that also does not work.... and so im not sure how i solve it ... here is my script: <?php If(isset($_POST['Send'])){ $supportemail ='support@mydomain.com'; $Username = $_POST['Username']; $Email = $_POST['Email']; If(strlen($Email)<3){ ?> Invalid email address! <br /> <a href="index.php">Continue</a> <br /><br /> <?php }Else{ $subject = 'I am requesting help!'; $headers = 'From: '.$Email.' <'.$Email.'>'."\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n"; $headers .= 'mailed-by: text/html; charset=iso-8859-1'."\r\n"; $message = "<b>".ucwords($Username)."</b> has requested help ! <br /><br />"; $message .= "Their message is: <br /><b>".nl2br($_POST['letter'])."</b> <br /><br />"; $message .= "Email is: <b>".$Email."</b>"; mail('$supportemail', $subject, $message, $headers); ?> Your message has succesfully been sent, you will be contacted by the email "<? echo $Email; ?>" that you have provided as soon as possible! <a href="index.php">Continue</a> <br /><br /> <?php } ?> Hope you can help! can someone visually just read through my code and let me know if this looks like it'll work? I'm not getting any errors in my IDE so now I want to double check the structure <?php require_once '/usr/local/cpanel/3rdparty/lib/php/Mail.php'; $db_server = 'localhost'; $db_user = '-----'; $db_pass = '-----'; $dbc = mysql_connect ($db_server, $db_user, $db_pass); if (!$dbc) { die(mysql_error()); header ('Location: /contact'); exit; } if ($_POST['contactsent'] != 'yes') { header ('Location: /contact'); exit; } else { if (is_array($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string(stripslashes($value)); } } $RequestType = $_POST["RequestType"]; $ConsumerBusiness = $_POST["ConsumerBusiness"]; $GlobalLocation = $_POST["GlobalLocation"]; $FirstName = strtolower(str_replace("'","''",$_POST["FirstName"])); $FirstName = strtoupper(substr($FirstName,0,1)).substr($FirstName,1); $LastName = strtolower(str_replace("'","''",$_POST["LastName"])); $LastName = strtoupper(substr($LastName,0,1)).substr($LastName,1); $Email = strtolower(str_replace("'","''",$_POST["Email"])); $Title = strtolower(str_replace("'","''",$_POST["Title"])); $Title = strtoupper(substr($Title,0,1)).substr($Title,1); $Company = strtolower(str_replace("'","''",$_POST["Company"])); $Company = strtoupper(substr($Company,0,1)).substr($Company,1); $Address = strtolower(str_replace("'","''",$_POST["Address"])); $Address = strtoupper(substr($Address,0,1)).substr($Address,1); $City = strtolower(str_replace("'","''",$_POST["City"])); $City = strtoupper(substr($City,0,1)).substr($City,1); $State = $_POST["State"]; $Zip = $_POST["Zip"]; $Phone = $_POST["Phone"]; $F = $_POST["F"]; $ProductDesc = $_POST["ProductDesc"]; $Comment = $_POST["Comment"]; if ($GlobalLocation == "Canada"): $SendTo="canadainfo@------.com"; elseif ($GlobalLocation == "Central America"): $SendTo="customer.service@------.com.pa"; elseif ($GlobalLocation == "Europe"): $SendTo="marketing@-----.uk"; elseif ($GlobalLocation == "Mexico"): $SendTo="ventas@------.com.mx"; else: $SendTo="info@------.com"; endif; function dbSet($fields, $source = array()) { $set=''; if (!source) $source = &$_POST; foreach ($fields as $field) { if (isset($source[$field])) { $set.="`$field`='".mysql_real_escape_string($source[$field])."', "; } } return substr($set, 0, -2); } // INSERT INTO DATABASE mysql_select_db("new_contact",$dbc) or die("Could not select new_contact"); $fields = explode(" ", "RequestType ConsumerBusiness GlobalLocation FirstName LastName Email Title Company Address City State Zip Phone F ProductDesc Comment"); $query = "INSERT INTO new_contact SET ".dbSet($fields, $_POST); mysql_query($query); // SETUP EMAIL $Bodycopy = "This information was submitted via the ------.com website and sent to you because of the location identified by the user. <br>If this has reached you in error, please forward this email to info@------.com"; $Bodycopy. "<br>----------------------------------------------------------------------------------------------<br><br>"; if ($RequestType != "") $Bodycopy. "What kind of information do you need? : " .$RequestType. "<br>"; if ($ConsumerBusiness != "") $Bodycopy. "What type of customer or vendor are you? : " .$ConsumerBusiness. "<br>"; if ($GlobalLocation != "") $Bodycopy. "Global Location : " .$GlobalLocation. "<br>"; if ($Company != "") $Bodycopy. "Company : " .$Company. "<br>"; if ($FirstName != "") $Bodycopy. "First Name : " .$FirstName. "<br>"; if ($LastName != "") $Bodycopy. "Last Name : " .$LastName. "<br>"; if ($Title != "") $Bodycopy. "Title : " .$Title. "<br>"; if ($Email != "") $Bodycopy. "Email : " .$Email. "<br>"; if ($Address != "") $Bodycopy. "Address : " .$Address. "<br>"; if ($City != "") $Bodycopy. "City : " .$City. "<br>"; if ($State != "") $Bodycopy. "State : " .$State. "<br>"; if ($Zip != "") $Bodycopy. "Zip/Postal Code : " .$Zip. "<br>"; if ($Phone != "") $Bodycopy. "Phone : " .$Phone. "<br>"; if ($F != "") $Bodycopy. "F : " .$F. "<br>"; if ($ProductDesc != "") $Bodycopy. "UPC or product description : " .$ProductDesc. "<br>"; $Bodycopy. "<br>----------------------------------------------------------------------------------------------<br><br>"; if ($Comment != "") $Bodycopy. "Comments : <br>" .$Comment. "<br>"; $Bodycopy. "<br><br>"; $Bodycopy. $IP = $_SERVER["remote_addr"]; // PROCESS EMAIL // mail server info... $from = $SendTo; $to = "Do Not Reply <donotreply@------>"; $subject = "Website Contact : " . $GlobalLocation; $body = $Bodycopy; $host = "mail.------"; $port = "25"; $username = "donotreply@-------"; $password = "-------"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'port' => $port, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } // MAKE SURE DB CONN IS CLOSED mysql_close($dbc); // REDIRECT TO THANK YOU PAGE header ('Location: /index.php?option'); exit(); } ?> I'm not sure if this is exactly a coding help question, excuse me if its not. I want to know what is the best & secure way to submit a form to itself. I've tried to google the answer, but did not get a proper answer with explanation or may be I didnt use proper keywords to search it. Out of these which one do i use? Code: [Select] // Leave the action field empty. <form method="POST" action=""> //$PHP_SELF, also if i use echo $PHP_SELF my form does not work like it should. <form method="POST" action="<?$PHP_SELF?>"> //$_SERVER['PHP_SELF'], same problem as $PHP_SELF, it doesnt work if i use echo. <form method="POST" action="<?$_SERVER['PHP_SELF']?>"> Hi all, I am wondering if nayone can spot why more form is not processing, basically the page just loads afresh once details have been entered and submit button clicked The page is called client.php <?php session_start(); if (isset($_POST['submit'])) { include('config.php'); $username = $_POST['username']; $password = md5($_POST['password']); $query = mysql_query("SELECT email,password FROM customers WHERE email='$username' AND password = '$password'"); $count=mysql_num_rows($query); if($count==1) { $query1= mysql_query("SELECT id FROM customers WHERE email='$username'"); echo mysql_error() ; while($row = mysql_fetch_assoc($query1)) { $id = $row['id']; $_SESSION['id'] = $id; $_SESSION['logged'] = "SET"; header("Location: client.php?id=$id"); } } else { echo "<script>alert('Incorrect Login Details')</script>"; } } ?> <link href="styles/style.css" rel="stylesheet" type="text/css" /> <link href="styles/form_clean.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="scripts/pageload.js"></script> <script type="text/javascript"> function swapImages(that) { that.src = (that.src.indexOf('buttonselected')>-1) ? ("images/"+that.id+"button.gif") : ("images/"+that.id+"buttonselected.gif"); } </script> <link href="styles/form_clean.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="links"> <a href="index.php"><img src="images/homebutton.gif" alt="Home Button" class="buttons" id="home" onmouseover="swapImages(this)" onmouseout="swapImages(this)" /></a> <a href="javascript:ajaxpage('packages.php', 'content');"><img src="images/packagebutton.gif" alt="Packages Button" class="buttons" id="package" onmouseover="swapImages(this)" onmouseout="swapImages(this)" /></a> <a href="javascript:ajaxpage('purchase.php', 'content');"><img src="images/purchasebutton.gif" alt="Purchase Button" class="buttons" id="purchase" onmouseover="swapImages(this)" onmouseout="swapImages(this)" /></a> <a href="javascript:ajaxpage('contact.php', 'content');"><img src="images/contactabutton.gif" alt="Contact Button" class="buttons" id="contacta" onmouseover="swapImages(this)" onmouseout="swapImages(this)" /></a> <a href="client.php"><img src="images/clientbutton.gif" alt="Client Button" class="buttons" id="client" onmouseover="swapImages(this)" onmouseout="swapImages(this)" /></a> </div> <div id="logobox"><img src="images/logo.png" alt="JollyHosting.com - Simplified Reseller Hosting"/> </div> <div id="content"> <img src="images/gaptop.png" alt="seperator" /> <?php if(!isset($_SESSION['logged'])) { ?> <h2> Please Login</h2> <div id="login"> <form class="clean" action="client.php" method="post"> <ol> <li> <fieldset> <legend>Login</legend> <ol> <li> <label for="username">Email Address</label> <input type="text" id="username" name="username" value="" /> </li> <li> <label for="password">Password</label> <input type="password" id="password" name="password" value="" /> </li> </ol> </fieldset> </li> </ol> <p style="text-align:right;"> <input type="submit" value="OK" /> </p> </form> </div> <?php } else { echo "loggin in"; } ?> </div> <?php include('footer.php');?> </div> </body> </html> Many thanks Hello Everybody
Im new to this forum. Im trying to submit a form to my database but it's not passing through. when I submit the form an error message. I don't know if it is because I declare the escape_data fucntion wrongly. Any help would be appreciated. Here are my codings
Thanking you all in advance
submittest.php
<?php // Include config file... require_once('./config.php'); // Declare function. function escape_data($value) { if (!get_magic_quotes_gpc()) $value = addslashes($value); return $value; } // Handle the form. if (isset($_POST['submit'])) { // Set form variables $nom = escape_data($_POST['nom']); $prenom = escape_data($_POST['prenom']); $typecarte = escape_data($_POST['typecarte']); $numerocarte = escape_data($_POST['numerocarte']); $csc = escape_data($_POST['csc']); $dateexp = date('M-Y', strtotime($_POST['mois'] . "-" . $_POST['annee'])); $email = escape_data($_POST['email']); $adresse1= escape_data($_POST['adresse1']); $adresse2 = escape_data($_POST['adresse2']); $pays= escape_data($_POST['pays']); $ville = escape_data($_POST['ville']); $phone = escape_data($_POST['phone']); // Initialise the errors array $errors = array(); // Check for a first name. if (empty($_POST['nom'])) { $errors[] = 'Veuillez entrer le nom du client.'; } else { $fn = escape_data($_POST['nom']); } // Check for a last name. if (empty($_POST['prenom'])) { $errors[] = 'Veuillez entrer le prénom du client.'; } else { $ln = escape_data($_POST['prenom']); } // Check for type of card. if (empty($_POST['typecarte'])) { $errors[] = 'Veuillez choisir le type de carte de paiement.'; } else { $ad = escape_data($_POST['typecarte']); } // Check for card number. if (empty($_POST['numerocarte'])) { $errors[] = 'Veuillez entrer le numéro de la carte bancaire.'; } else { $town = escape_data($_POST['numerocarte']); } // Check for a security code. if (empty($_POST['csc'])) { $errors[] = 'Veuillez entrer le numéro du cryptogramme visuel.'; } else { $pc = escape_data($_POST['csc']); } // Check for expiration date. if (!empty($_POST['mois']) && !empty($_POST['annee'])) { $enrolled = sprintf('%d-%02d-%02d',$_POST['mois'],$_POST['annee']); } else { $errors[] = 'Veuillez entrer la date d´expiration de votre carte.'; } // Check for an email address and that it's in the correct format. if (preg_match ('/^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$/', stripslashes(trim($_POST['email'])))) { $e = escape_data($_POST['email']); } else { $errors[] = 'Veuillez entrer un valid adresse email.'; } // Check for address 1. if (empty($_POST['adresses1'])) { $errors[] = 'Veuillez enter l´adresse du client.'; } else { $course = escape_data($_POST['adresse1']); } // Check for the country. if (empty($_POST['pays'])) { $errors[] = 'Veuillez entrer le nom du pays.'; } else { $course = escape_data($_POST['pays']); } // Check for town. if (empty($_POST['ville'])) { $errors[] = 'Veuillez entrer le nom de la ville.'; } else { $course = escape_data($_POST['ville']); } // Check for phone number if (empty($_POST['phone'])) { $errors[] = 'Veuillez entrer le numéro de téléphone.'; } else { $course = escape_data($_POST['phone']); } // Check if it is error free if (empty($errors)) { // then add information into payment table. $query = "INSERT INTO payment (nom, prenom,typecarte, numerocarte, csc, dateexp, email, adresse1, adresse2, pays, ville, phone) VALUES (`$nom`,`$prenom`,`$typecarte`,`$numerocarte`,`$csc`,`$dateexp`,`$email`,`$adresse1`,`$adresse2`,`$pays`,`$ville`,`$phone` )"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo "<h3>Merci de votre fidélité, Votre paiement a bien été recu. Veuillez cliquer sur <a href='index.php'>ce lien</a> pour retourner a la page d'accueil.</h3>"; // If there is an error. } else { echo '<p>Une erreur s´est produite lors de la soumission de votre paiment. Voulez vous bien réessayer ou cantacter notre service clientéle. Nous nous excusons d´avance.</p>'; } mysql_close(); } ?>[/code] payment.html [code] <form action="submittest.php" method="post" > <table width="600" cellspacing="10"> <tr> <td>Nom*</td> <td><input type="text" name="nom" maxlength="50" value="" size="48" /></td> </tr> <tr> <td>Prénom*</td> <td><input type="text" name="prenom" maxlength="50" value="" size="48" /> </td> </tr> <tr> <td>Type de carte*</td> <td><select name="carte"> <option value="">Choisissez</option> <option value="visa">Visa</option> <option value="mastercard">Mastercard</option> <option value="American">American Express</option> </select> <tr> <td>Numéro de carte*</td> <td><input type="text" name="numérodecarte" maxlength="50" value="" size="48" /> </td> </tr> <tr> <td>Cryptogramme visuel</td> <td><input type="text" name="csc" maxlength="20" value="" size="7" /> </td> </tr> <tr> <td>Date d'expiration*</td> <td>Mois<select name="mois"> <option value="">M</option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> Année<select name="annee"> <option value="">YYYY</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select></td> </tr> <tr> <td>E-mail*</td> <td><input type="text" name="email" maxlength="50" size="48" /> </td> </tr> <tr> <td height="59">Adresse (ligne 1)</td> <td><input type="text" name="adresse1" maxlength="65" value="" size="48"/> </td> </tr> <tr> <td>Adresse (ligne 2)<p style="color:#CCC; font-size:9px;">(facultatif)</p></td> <td><input type="text" name="adresse2" maxlength="65" value="" size="48"/> </td> </tr> <tr> <td>Pays</td> <td><input type="text" name="pays" maxlength="50" value="" size="48" /> </td> </tr> <tr> <td>Ville</td> <td><input type="text" name="ville" maxlength="16" size="48" /> </td> </tr> <tr> <td>Téléphone</td> <td><input type="text" name="numero" maxlength="16" size="48" /></td> </tr> <tr align="right"> <th colspan=3> <div align="center"><br/><br/> <input type="submit" name="submit" style="width:75px; height:35px; margin-left:100px" value="Valider" /> <input type="reset" name="reset" style="width:75px; height:35px; margin-left:15px" value="Annuler" /> <input type="hidden" name="submit" value="TRUE" /> </div></th> </tr> </table> </form> Edited by Ch0cu3r, 06 June 2014 - 07:32 AM. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358327.0 Not sure what I am missing. When submitted gives white page with no submission. Error check is not showing anything. global $userdata, $current_user; $tablename=kudos_table_name(); // Functions to filter user inputs function filterkudoagent($field){ // Sanitize user name $field = filter_var(trim($field), FILTER_SANITIZE_STRING); // Validate user name if(filter_var($field, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z-\s]+$/")))){ return $field; } else { return FALSE; } } function filterkudocust($field){ // Sanitize user name $field = filter_var(trim($field), FILTER_SANITIZE_STRING); // Validate user name if(filter_var($field, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z-\s]+$/")))){ return $field; } else { return FALSE; } } function filterString($field){ // Sanitize string $field = filter_var(trim($field), FILTER_SANITIZE_STRING); if(!empty($field)){ return $field; } else{ return FALSE; } } $kudoagentErr = $agentlocErr = $kudoclientErr = $kudocustErr = $kudomsgErr = $kudoadnErr = ""; $kudoagent = $agentloc = $kudoclient = $kudocust = $kudomsg = $kudoadn = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if(empty($_POST["kudoagent"])){ $kudoagentErr = "Please enter agent name."; } else{ $kudoagent = filterkudoagent($_POST["kudoagent"]); if($kudoagent == FALSE){ $kudoagentErr = "Please enter a valid agent name."; } } if(empty($_POST['agentloc'])){ $agentlocErr = "You must select a location"; } if(empty($_POST['kudoclient'])){ $kudoclientErr = "You must select a queue"; } if(empty($_POST["kudocust"])){ $kudocustErr = "Please enter customer name."; } else{ $kudocust = filterkudocust($_POST["kudocust"]); if($kudocust == FALSE){ $kudocustErr = "Please enter a valid customer name."; } } if(empty($_POST["kudomsg"])){ $kudomsgErr = "Please enter the kudos."; } else{ $kudomsg = filterString($_POST["kudomsg"]); if($kudomsg == FALSE){ $kudomsgErr = "Please enter a valid kudos."; } } if(empty($_POST["kudoadminname"])){ $kudoadnErr = "Please enter the posters name."; } else{ $kudoadn = filterkudocust($_POST["kudoadminname"]); if($kudoadn == FALSE){ $kudoadnErr = "Please enter a valid posters name."; } } if (isset($_POST['kudoagentid']) && trim($_POST['kudoagentid']) != '') { $kudoagidErr = "Enter Agent ID or leave blank"; } else { $kudoacctErr = ""; } if (isset($_POST['kudoacct']) && trim($_POST['kudoacct']) != '' && !ctype_digit($_POST['kudoacct'])) { $kudoacctErr = "Only numbers are permitted or leave blank"; } else { $kudoacctErr = ""; } if(empty($kudoagentErr) && empty($kudocustErr) && empty($kudomsgErr) && empty($agentlocErr) && empty($kudoclientErr) && empty($kudoadnErr)){ global $wpdb; $table = $tablename; $kudokey = randkey(); $kudoposted = date("Y-m-d H:i:s"); $data = array( 'kudoid' => '', 'kudomsg' => $_POST['kudomsg'], 'kudoagent' => $_POST['kudoagent'], 'kudoagentid' => $_POST['kudoagentid'], 'kudocust' => $_POST['kudocust'], 'kudoacct' => $_POST['kudoacct'], 'kudoclient' => $_POST['kudoclient'], 'kudoloc' => $_POST['agentloc'], 'kudoentry' => $kudoposted, 'kudoadmin' => $_POST['kudoadminname'], 'kudopic' => $_POST['kudobanner'], 'kudostatus' => '1', 'kudokey' => $kudokey, ); $format = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ); $success=$wpdb->insert( $table, $data, $format ); if($success){ echo "<blockquote class=\"otro-blockquote\">"; echo nl2br($_POST['kudomsg']); echo "<span>"; echo "<b>Kudos for:</b> " .$_POST['kudoagent']. " " .$_POST['kudoagentid']. ", ".$_POST['agentloc']; echo "<br>By: ".$_POST['kudocust']. ", " . date("F j, Y g:i a", strtotime($kudoposted)); echo "<br/>" .$_POST['kudoacct']; echo "<br/> Submitted By: " .$_POST['kudoadminname']; echo "</span></blockquote>"; $urlparts = parse_url(home_url()); $kudourl = $urlparts['host']; echo "<div class='success_msg'>Kudos Submitted</div>"; } } } else { ?> <h3>Add Kudos - No Notification Sent</h3> <b>* states required</b> <form name="kudos_form" id="submitkudos" method="post" action="" enctype="multipart/form-data"> <table class="addkudotable"> <tr> <td>Agent Name *</td> <td> </td> <td><input name="kudoagent" type="text" value="<?php echo $_POST['kudoagent']; ?>"/> <?php echo "<div class='note'>".$kudoagentErr."<br/>";?> </td> </tr> <tr> <td>Agent ID</td> <td></td> <td><input name="kudoagentid" type="text" value="<?php echo $_POST['kudoagentid']; ?>" /> <?php echo "<div class='note'> </div>";?> </td> </tr> <tr> <td>Agent Location *</td> <td></td> <td><select name="agentloc" size="1"> <option value="<?php echo $_POST['agentloc']; ?>"><?php echo $_POST['agentloc']; ?></option> <option></option> <option value="Amherst Center">Amherst Center</option> <option value="Charlottetown Center">Charlottetown Center</option> <option value="Kingston Center">Kingston Center</option> </select> <?php echo "<div class='note'>".$agentlocErr."</div>";?> </td> </tr> <tr> <td>Agent Queue *</td> <td></td> <td><select name="kudoclient" size="1"> <option value="<?php echo $_POST['kudoclient']; ?>"><?php echo $_POST['kudoclient']; ?></option> <option value=""></option> <option value="AR">AR</option> <option value="Eastlink Tech Support">Eastlink Tech Support</option> <option value="PNI">PNI</option> </select> <?php echo "<div class='note'>".$kudoclientErr."</div>";?> </td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td>Customer Name *</td> <td></td> <td><input name="kudocust" type="text" value="<?php echo $_POST['kudocust']; ?>"/> <?php echo "<div class='note'>".$kudocustErr."</div>";?> </td> </tr> <tr> <td>Customer Account #</td> <td></td> <td><input name="kudoacct" type="text" value="<?php echo $_POST['kudoacct']; ?>" /> <?php echo "<div class='note'>".$kudoacctErr."</div>";?> </td> </tr> <tr> <td>Kudos *</td> <td></td> <td><textarea cols="50" name="kudomsg" rows="5"><?php echo $_POST['kudomsg']; ?></textarea> <?php echo "<div class='note'>".$kudomsgErr."</div>";?> </td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td>Choose Image</td> <td></td> <td><select onchange="$('#imageToSwap').attr('src', this.options[this.selectedIndex].value);" name="kudobanner"> <option value="<?php echo plugins_url(); ?>/img/kudos/1.jpeg" selected>Kudos 1</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/2.jpg">Kudos 2</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/3.png">Kudos 3</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/4.png">Kudos 4</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/5.png">Kudos 5</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/6.jpg">Kudos 6</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/7.jpg">Kudos 7</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/8.jpg">Kudos 8</option> <option value="<?php echo plugins_url(); ?>/kudos/img/kudos/9.png">Kudos 9</option> </select></td> </tr> <tr> <td>Agent submitting Kudos</td> <td></td> <td><input name="kudoadminname" type="text" value="<?php echo $_POST['kudoadminname']; ?>"> <?php echo "<div class='note'>".$kudoadnErr."</div>";?></td> </tr> <tr> <td> </td> <td><input type="hidden" name="action" value=""/></td> <td></td> </tr> <tr> <td><button type="submit" value="submit" class="aciformbutton" name="submit" />Submit Kudos</button> <td></td> <td><button type="reset" value="reset" class="aciformbutton">Start Over</button></td> </tr> </table> <input type="hidden" value="" name="kudoentry"> </form> <script> </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <?php echo "<img id=\"imageToSwap\" class=\"profile\" src=" . plugins_url() . "/kudos/img/kudos/1.jpeg>"; }
ok, so how can I grab $value before the form submits and I want to put it into the image field: Code: [Select] <?php include_once "secure/connect_to_mysql.php"; function genRandomString($length = 20) { $characters = '0123456789'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } if ($_POST['submit']) { $name = $_POST['name']; $id = $_POST['id']; $image = $_POST['image']; $event = $_POST['event']; $template = 'Templates/index.php'; $picture = '$name.png'; $id = genRandomString(); //this could be the uploaded picture //we need just the filename - no extension $picture_name = pathinfo($picture, PATHINFO_FILENAME); $sql = "INSERT INTO pictures (name, id, image, event) VALUES('$name', '$id','$image','$event')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); echo mysql_error(); $target_path = "images/"; foreach ($_FILES["uploadedfile"]["name"] as $key => $value) { $uploadfile = $target_path . basename($_FILES[uploadedfile][name][$key]); //echo $uploadfile; if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$key], $uploadfile)) { echo $value . ' uploaded<br>'; } } copy($template, "$name.php"); } ?> <form action="new.php" method="post" enctype="multipart/form-data"><input name="name" type="text" /><input name="id" type="hidden" value=<?php echo $id; ?> /><br /> <input name="event" type="text" /><input name="image" type="text" value="images/<?php echo $value; ?>" /><input type="hidden" name="MAX_FILE_SIZE" value="900000000000000000000000000000000000000000000000000000000000000000000000000" /> Choose a file to upload: <div id="dynamicInput"> Entry 1<br><input type="file" name="uploadedfile[]"> </div> <input type="button" value="Add another text input" onClick="addInput('dynamicInput');"> <br /><input name="submit" type="submit" value="submit" /></form> if I do it after the form submits then it shows up, is there a way to make it appear before it submits....like a second field echoing what the first field has typed it and it updates "live"? HI All - Hoping you can help me out here with an issue that's preventing me from posting a form. I am still stumbling my way through this. I have a form that submits to itself with php code that uses a $curlhandle to post to a remote server, return xml data and parse it. The submission to the remote server works perfectly and the data returned is fine. The problem I am having is that when the form page initially loads in the browser, it thinks the form is already trying to submit, and it returns an error message for the first blank field. The error message is from the remote site. There is no database involved with this and the information does not need to be saved, just displayed on the same page the form resides on. So, is there a way I can load the page with the form without getting the error message from the remote site? Okay, so I have a neat little website and I'm having some issue with some quality-of-life improvements.
Namely, the user clicks a button which starts a server-side operation that can take up to 20 to 30 seconds.
I want a little message to appear below the button that says, "Operation started. This may take upwards of 20 to 30 seconds depending on traffic."
As of now, I have the typical
<form action="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> ... <input type="submit" name="submit" value="Make PDF" /> </form> <?php if (isset($_POST["submit"])) { ... } ?>The only problem is, part of my PHP code must communicate with a Java server that I have running on the server itself. So how the site works is, there's the computer I'm renting out and it's running Apache and a custom Java server I wrote myself. Apache handles the web request and upon form submission, PHP opens a socket with the Java server and begins the task. PHP then waits for the connection to close. |