PHP - Php Code Help Desparately Needed *please*
I have a mysql database. I have some PHP code that I can view the mysql data & add data to the mysql database. I've attached a photo to look at. You will see an "Edit" button at the end. I need to be able to click on the edit button & it will bring up another page so I can edit that particular record. I do have an ID field in the mysql database that is set to auto inrement so each record has it's own ID. I have no clue where to start as I know very little about PHP. The mysql database name is flow & the table name is info. The fields in the database that you see in the photo is due_ge, due_ny, and due_rk. The page I go to view the data in the mysql database is named view.php & the file I use to enter a new record is named add.php. If I could click the "edit" button to somehow edit these date fields that would be great!! Could someone start me in the right direction?
Similar TutorialsThe attached code pulls data from a mysql database & displays it in a form so I can edit it. I need to be able, when a user clicks the submit button in this code, the data is updated in the mysql database, and sends that data to an email address based off of the location. At this time I just have first name, lastname, and location in there. So if a user chose office1 the data would go to office1@mail.com. Everything works except the email part. I thought I had it earlier but was wrong. Can someone please assist? Thanks Code: [Select] <?php # edit_dqa.php $page_title = 'Edit a Record'; $con = mysql_connect("localhost","uname","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("psrflow", $con); if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // Accessed through view_users.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; include ('./includes/footer.html'); exit(); } $query = "UPDATE psrinfo SET fname='$fn', lname='$ln', location='$loc' WHERE fid=$id"; $result = @mysql_query ($query); // Run the query. // Send mail according to location switch($_REQUEST['location']) { case "office1": $email = "myemail@yahoo.com"; break; default: echo "Error, no location selected!!!"; break; } $Message = "<p>An employee has edited the information below.</p><br> Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}"; $Headers = "MIME-Version: 1.0\n"; $Headers .= "Content-type: text/html; charset=iso-8859-1\n"; $Subject = "Please Review"; $Headers .= "To: DQA <$EmailAddress>\n"; $Headers .= "From: The Database <sender email>\n"; $SendMail = mail($EmailAddress, $Subject, $Message, $Headers); if (mail($EmailAddress, $Subject, $Message, $Headers)) { echo "<center>An email has been sent for editing"; } else { echo "This system is not working properly. Please contact a tech."; } $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) { $url = substr ($url, 0, -1); } $url ='/flow/index.html'; header("Location: $url"); exit(); } else { // Report the errors. echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } // End of if (empty($errors)) IF. } // End of submit conditional. // Retrieve the user's information. $query = "SELECT pacts, fname, lname, location WHERE fid = " . $_REQUEST['id']; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // Valid user ID, show the form. $row = mysql_fetch_array ($result, MYSQL_NUM); ?> <?php echo '<form action="edit_dqa.php" method="post"> <fieldset><legend><h1> You are editing a record!</h1></legend> <b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br /> <b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br /> <b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br> br> <br> </fieldset> <div align="left"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { // Not a valid user ID. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. ?> The following code looks at my MySQL database at the due_owner field. This is a date field & if the due_owner date is less within 6 days of the current date, it sends an email to the $email variable. This code works great! The only issue I have is, is there ANY way for me to adjust this code so it will stop sending emails after the date listed in the due_owner field? At this time, the email address listed in teh $email variable still gets an email after the date in the due_owner field. If this is not possible, is it possible to adjust the code so it will only send the email one time? I have this code as part of a script that runs each night at midnight...Thanks Code: [Select] <?php include('connection.php'); $number_of_days_before = 6; $email = "employee1@email.org"; $reminder_details = ""; $todays_date = date( "Ymd" ); echo $todays_date; $year = substr($todays_date, 0, 4); $month = substr($todays_date, 4, 2); $date = substr($todays_date, 6, 2); $trigger_date = date("Ymd", mktime(0,0,0,$month, $date-$number_of_days_before,$year)); echo $trigger_date; $result = mysql_query( "SELECT due_owner, employee, pacts, dock, name, lname FROM psrinfo WHERE employee='Jane Doe' AND due_owner <= $trigger_date" ); $nr = mysql_num_rows( $result ); while( $row = mysql_fetch_array( $result ) ) { $reminder_details .= "Name: ".$row["fname"]." ".$row["lname"]."\n"; $reminder_details .= "PACTS Number: ".$row["pacts"]."\n"; $reminder_details .= "Dock: ".$row["dock"]."\n"; $reminder_details .= "Due to Owner: ".$row["due_owner"]."\n\n\n"; } mysql_free_result( $result ); if( !empty( $nr ) ) { $mailheader = "From: The Reminder System <$email>\nX-Mailer: Reminder\nContent-Type:text/plain"; mail("$email", "Due to Within 6 Days", "$reminder_details", "$mailheader"); } ?> Hello, I have successfully made a script that will upload images to the album of my facebook page easily. Following is the link to that script http://radiations3.com/facebook/facebook_upload.php Now when i used the same script to upload status directly to my wall then the script is doing nothing kindly let me know what is the problem with my code Code: [Select] //posting to the page wall $attachment = array('message' => 'this is my message', 'access_token' => $access_token, 'name' => 'This is my demo Facebook application!', 'caption' => "Caption of the Post", 'description' => 'this is a description', 'picture' => 'http://radiations3.com/images/logo.png', ); $status = $facebook->api('/194458563914948/feed', 'POST', $attachment); // my page id =123456789 var_dump($status); Hi, Posted here as it is in regards to PHP code making MySQL queries. Let's say i had this code below: <?php # Databse query $query = mysql_query("SELECT id, admin, username, first_name, last_name, email FROM `users` WHERE username = '$username' AND password = '$password' LIMIT 1"); # Check login query if(!$query){ echo 'Oops'; } else { echo 'Login Succesful'; } ?> Now this code with slight difference: <?php # Databse query $query = mysql_query("SELECT id, admin, username, first_name, last_name, email FROM `users` WHERE username = '$username' AND password = '$password' LIMIT 1"); # Check login query if(!$query){ echo 'Oops'; } else { if (mysql_num_rows($query) == 1) { echo 'Login Succesful'; } else { echo 'Login Details Invalid'; } } ?> Now my question is in the second lot of code; i am doing a check to ensure that the query is true in terms of username and password match database login credentials by doing mysql_num_rows as in code . Basically do i need to do that extra check in the second lot of code or is the first lot of code fine in checking username and password match database and if not return oops and return Oops if query fails for any other reason ? not sure if i am creating more code that is needed. I am slightly confused see in whether the extra check in second lot of code is needed or not. Could someone please explain in simple terms to me if it is or not and why? Thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=355529.0 I have 99% of the code written but I still need a line or two but can't figure it out. Due_Attny is a date field. This code looks at my MySQL database & if the due_attny field is between todays date & the trigger date it will send an email to the $email variable. There is also a field in my MySQL database named a_mail_sent that by default is set to 0 which means an email has not been sent. I need to edit this code so it will look at the a_email_sent field & if the value is 0, it sends the email & updates the a_email_sent field to 1 which means the email has been sent. If the a_mail_sent field has a value of 1, I don't need the email to be sent. Can somoeone help me out with this code? Thanks Code: [Select] <?php include('connection.php'); // DB connection // Constants $number_of_days_before = 6; $email = "emailaddress@mail.org"; $reminder_details = ""; $todays_date = date( "Ymd" ); echo $todays_date; $year = substr($todays_date, 0, 4); $month = substr($todays_date, 4, 2); $date = substr($todays_date, 6, 2); $trigger_date = date("Ymd", mktime(0,0,0,$month, $date+$number_of_days_before,$year)); $insertquery = "UPDATE psrinfo SET a_mail_sent=1 WHERE employee='Employee1'"; mysql_query($insertQuery) or die ('Error updating database'); echo $trigger_date; $result = mysql_query( "SELECT a_mail_sent, due_attny, employee, pacts, dock, fname, lname FROM psrinfo WHERE employee='Employee1' AND due_attny BETWEEN $todays_date AND $trigger_date" ); $nr = mysql_num_rows( $result ); while( $row = mysql_fetch_array( $result ) ) { $reminder_details .= "Name: ".$row["fname"]." ".$row["lname"]."\n"; $reminder_details .= "PACTS Number: ".$row["pacts"]."\n"; $reminder_details .= "Dock: ".$row["dock"]."\n"; $reminder_details .= "Due to Attny: ".$row["due_attny"]."\n\n\n"; } mysql_free_result( $result ); if( !empty( $nr ) ) { // Send reminder email $mailheader = "From: Reminder System <$email>\nX-Mailer: Reminder\nContent-Type:text/plain"; mail("$email", "PSR Due Within 6 Days", "$reminder_details", "$mailheader"); } ?> I have a webpage where the candidates can attach their resumes and send to the admin.These attachments are saved in the mysql db as blob datatype.In another webpage the admin needs to download all this resumes and see the content. How will i code for that. I hav a php page which takes data from the db.But the problem i am facing is for a particular fild in database ,i have long data,which i need to b displayed in a wordwrap way eg my data is " Description need a site for school gave order on 12-10-2010 work started on 12-10-2010 " this shuld be displayed as "Description need a site for school gave order on 12-10-2010 work started on 12-10-2010" Description is the field in the database and rest of them are the datas in it Hello Freaks! I am having problem with following code: <?php simplexml_load_string ('?xml version="1.0" encoding="utf-8"?>'); php?> This code is giving me following error Parse error: syntax error, unexpected '<' in public_html/wp-content/plugins/pluginnamehere/whatever.php on line 665 I know there is only a minor bracket problem that causing me this error. I would be helpful to you if you can modify it for me Thanks I have a small project. I have a control board that is connected to the parallel port. It controls 8 strips of LED on the LPT1 port. I can turn these on and off via the command prompt, using LPTOUT.exe ie lptout 1 turns on the 1st LED lptout 2 will turn off 1st LED and turn on 2nd, lptout 4 turns on 3rd and 2nd off, etc 1, 2, 4, 8, 16, 32, 64, 128. and combinations ie lptout 3 turns on LEDS 1 and 2, and so on. However lptout seems very unresponsive sometimes I have to do lptout 1 twice before LED 1 turns on. Is there another command I can use to write to LPT1 port. I need some PHP code to control the outputs. I want to sequence the outputs ie 1on (1second) 2on (1 second) 3 on (1 second) 4 on etc. to 8, then all off then repeat. Can anyone help me. THANK YOU. Hi guys, I am making a bot which only scrapes the source code of the site AFTER logging into the site.The script to login is : Code: [Select] <?php $username="xxx"; $password="iwonttellyou"; $url="http://internet.com/login.php"; $cookie="cookie.txt"; $postdata = "name=".$username."&password=".$password; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); echo $result; ?> I can see different SESSION ID's in cookie.txt everytime i compile this code, which makes me believe its working.However what next? How should i go to that site again, already logged in and scrape the data ? Some suggestions would be nice. Hello: I have a small chunck of code that dosplays data depending on which PlayerID is selected. Like so: Code: [Select] <?php $myvar = $_REQUEST['PlayerID']; ?> ... <?php if ( $myvar == "1" ) { echo "Your name is Tina"; } elseif ( $myvar == "2" ) { echo "Your name is Sue"; } else { echo "Your name is Jill"; } ?> This works fine - no errors - but I am use to ASP and using an "End If" after "Else" ... Is this not needed in PHP? Thanks. I have a form with dynamic text boxes that have dynamic names (i.e., TextBox1, TextBox2, etc.). How do I get those variables passed into php? I have tried and tried...even googled it, with no solid luck. Any help, immediately, would be so much appreciated. Hello i have coded a script that checks the post values then updates db recoreds thing is. i have this line of code if($name && $price && $ship && $paypal && $des && $cato_id !== ""){ do code }else{ do this } when the client enters 0 in the ship and price the do code does not get excuted how can i solve this problem thanks <?php # Script 10.3 - upload_image.php // This page is for editing a product. require_once(MYSQL);; // Check for a valid product ID, through GET or POST: if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; // Make the query: $q = "SELECT name, price, ship, paypal, descr FROM products WHERE product_id='$id' LIMIT 1"; $r = mysqli_query ($dbc, $q); if(mysqli_affected_rows($dbc) == 1) {//Ran Ok ready to delete file $row = mysqli_fetch_array ($r, MYSQLI_ASSOC); } } else { die('<p class="error">Sorry this page is not available or has been accessed in error</p>'); } // Check if the form has been submitted: if (isset($_POST['submitted'])) { require_once(MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $name = $price = $ship = $paypal = $des = $cato_id = FALSE; // Check for a product name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['name'])) { $name = mysqli_real_escape_string ($dbc, $trimmed['name']); } else { echo '<p class="error">Please enter a product name</p>'; } // Check for a price if (is_numeric($trimmed['price'])) { $price = mysqli_real_escape_string ($dbc, $trimmed['price']); } else { echo '<p class="error">Please enter a price</p>'; } // Check for a price if (is_numeric($trimmed['shipping_cost'])) { $ship = mysqli_real_escape_string ($dbc, $trimmed['shipping_cost']); } else { echo '<p class="error">Please enter a shipping cost</p>'; } // Check for paypal code: if ($_POST['paypal']) { $paypal = mysqli_real_escape_string ($dbc, $trimmed['paypal']); } else { echo '<p class="error">Please enter the paypal code</p>'; } // Check for product description: if ($_POST['product_des']) { $des = mysqli_real_escape_string ($dbc, $trimmed['product_des']); } else { echo '<p class="error">Please enter a product description</p>'; } // Check for product description: if ($_POST['cato_id']) { $cato_id = mysqli_real_escape_string ($dbc, $trimmed['cato_id']); } else { echo '<p class="error">Please Select a category</p>'; } if ($name && $price && $ship && $paypal && $des && $cato_id !== "") { // If everything's OK... $q = "UPDATE products SET name='$name', price='$price', ship='$ship', paypal='$paypal', descr='$des', cato='$cato_id' WHERE product_id='$id'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); echo '<p class="success"><em>The Product Information has Been Updated</em></p>'; } if($_POST['oldimage'] == 0){ // Check for an uploaded file: if (isset($_FILES['upload'])) { // Validate the type. Should be JPEG or PNG. $allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if (in_array($_FILES['upload']['type'], $allowed)) { function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['upload']['name']); //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $timestamp = time(); //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $default_name = $timestamp."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = TARGET; $image = "/photos/"; //This combines the directory, the random file name, and the extension $target = $target . $default_name.$ext; $image = $image . $default_name.$ext; // Move the file over. if (move_uploaded_file ($_FILES['upload']['tmp_name'], "$target")) { // Make the query: $q = "SELECT image FROM products WHERE product_id='$id' LIMIT 1"; $r = @mysqli_query ($dbc, $q); if(mysqli_affected_rows($dbc) == 1) {//Ran Ok ready to delete file $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $q = "UPDATE products SET image='$image' WHERE product_id='$id'"; $r = @mysqli_query ($dbc, $q); //Delete from file $myFile = DELPATH . $row[0]; if (file_exists($myFile)) { //Delete from file if(unlink($myFile)){ echo "<p class=\"success\">File: $row[0] has been successfully deleted</p>"; } } echo '<p class="success"><em>The Product Image has Been Changed</em></p>'; } } // End of move... IF. } else { // Invalid type. echo '<p class="error">Please upload a JPEG or PNG image.</p>'; } // Check for an error: if ($_FILES['upload']['error'] > 0) { echo '<p class="error">The file could not be uploaded because: <strong>'; // Print a message based upon the error. switch ($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini.'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk.'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error occurred.'; break; } // End of switch. print '</strong></p>'; } // End of error IF. // Delete the file if it still exists: if (file_exists ($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name']) ) { unlink ($_FILES['upload']['tmp_name']); } } // End of isset($_FILES['upload']) IF. } } i need help with mysql.php this keeps coming up when i try to log into my game Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/tassie12/domains/kronicalwars.co.cc/public_html/mysql.php on line 2 Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/tassie12/domains/kronicalwars.co.cc/public_html/mysql.php on line 3 Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/tassie12/domains/kronicalwars.co.cc/public_html/authenticate.php on line 30 Access denied for user 'root'@'localhost' (using password: YES) can someone send me the code for mysql.php for mccodes and tell me where to put the database user and pass? Hello Form, This is my first post here so hello to all . Ok now for my question. i am making an CMS system for a school project. we have decided to work with smarty. Now this question is about 2 tables. table 1: attributes it contains the collums 'att_Id, att_Lable and att_Name' table 2: pg_Data(page data) this contains the collums 'dat_Id, att_Id, dat_Lable and dat_Name' This table contains the values for the attributes from table 1. in short: |table 1 |------------------------------------------------| | att_Id | att_Lable | att_Name | |------------------------------------------------| | 1 | head | Head | |table 2 |------------------------------------------------------------| | dat_Id | att_Id | dat_Value | |------------------------------------------------------------| | 1 | 1 | This is a text | now i need a query that need a query that get out de att_label from table 1 en the value from table 2. Code: [Select] SELECT dat.dat_Value, att.att_Lable FROM pg_Attributes AS att LEFT JOIN pg_Data AS dat ON att.att_Id = dat.att_Id then i get an output in php array( [dat_Value] => this is a text [att_Lable] => head ) now this is all good but i want to get the lable of the attribute in de key of the value. So it would look like this. array( [head] => this is a text ) is there anyone how understands this and can help me let me know. Hello all,
Am trying to get the answers of a survey from my DB and display the percentage.. Everything am trying seems not to be working. please what am i doing wrong.
<? $question_query = "SELECT * FROM ".$tblprefix."question WHERE category = 'Service Availability' and section = 'Information Technology Services'"; $rs = $db->Execute($question_query); $all_the_time = array(); $most_of_the_time = array(); $sometimes = array(); $never = array(); while (!$rs->EOF) { $question_id = $rs->fields['question_id']; $question_query1 = "SELECT * FROM ".$tblprefix."user_answer, ".$tblprefix."question WHERE ".$tblprefix."user_answer.question_id = ".$tblprefix."question.question_id"; $rs1 = $db->Execute($question_query1); $answer_id = $rs1->fields['user_answer_id']; $question_query2 = "SELECT * FROM ".$tblprefix."answer WHERE answer_id = '$answer_id'"; $rs2 = $db->Execute($question_query2); $answer = $rs2->fields['answer']; if($answer == 'All the time') { array_push($all_the_time,'1'); } else if ($answer == 'Most of the time') { array_push($most_of_the_time,'1'); } else if ($answer == 'Sometimes') { array_push($sometimes,'1'); } else if($answer == 'Never') { array_push($never,'1'); } $rs->MoveNext(); } $count_all_of_time = count($all_the_time); $count_most_of_time= count($most_of_the_time); $count_sometimes = count($sometimes); $count_never = count($never); ?> <table border="0" class="question_answer_table"> <tr> <td><strong>Service Availability</strong></td> </tr> </table> <table border="0" class="question_answer_table"> <tr> <td style="width:120px;">All of Time</td> <td style="width:70px;"><?=round($count_all_of_time/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Most of Time</td> <td><?=round($count_most_of_time/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Sometimes</td> <td><?=round($count_sometimes/$totaluser*100,2) .'%'?></td> </tr> <tr> <td>Never</td> <td><?=round($count_never/$totaluser*100,2) .'%'?></td> </tr> </table>Only one of the field is displaying an output. the rest are not. thanks in advance Hello Forum, please can someone help me solve this error in the code below, thanks Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\XAMPP\xampp\htdocs\testingSite\addtobasket.php on line 10 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\XAMPP\xampp\htdocs\testingSite\addtobasket.php on line 11 <?php session_start(); require("db.php"); require("function.php"); $validid = pf_validate_number($_GET['id'], "redirect", $config_basedir); $prodsql = "SELECT * FROM products WHERE id =" .$_GET['id'] . "'"; $prodres = mysql_query($prodsql); $numrows = mysql_num_rows($prodres); $prodrow = mysql_fetch_assoc($prodres); if($numrows == 0) { header("Location: ". $config_basedir); } else { if($_POST['submit']) { if($_SESSION['SESS_ORDERNUM']) { $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] . "," . $_GET['id'] . "," . $_POST['amountBox'] .")"; mysql_query($itemsql); } else { if($_SESSION['SESSION_LOGGEDIN']) { $sql = "INSERT INTO orders(customer_id, registered, date) VALUES (" . $_SESSION['SESS_USERID'] . ", 1, NOW())"; mysql_query($sql); session_register("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES (" . $_SESSION['SESS_ORDERNUM'] .",". $_GET['id'] . "," . $_POST['amountBox'] . ")"; mysql_query($itemsql); } else { $sql = "INSERT INTO orders(registered, date, session) VALUES(" ."o, NOW(),'" . session_id() . "')"; mysql_query($sql); session_registered("SESS_ORDERNUM"); $_SESSION['SESS_ORDERNUM'] = mysql_insert_id(); $itemsql = "INSERT INTO orderitems(order_id, product_id, quantity) VALUES(" . $_SESSION['SESS_ORDERNUM'] . "," .$_GET['id'] . "," . $_POST['amountBox'] . ")"; mysql_query($itemsql); } } $totalprice = $prodrow['price'] * $_POST['amountBox']; $updsql = "UPDATE orders SET total + ". $totalprice . " WHERE id = " . $_SESSION['SESS_ORDERNUM'] . ";"; mysql_query($updres); header("Location: " . $config_basedir . "showcart.php"); } else { require("header.php"); echo "<form action='addtobasket.php?id=" .$_GET['id'] . "' method='POST'>"; echo "<table cellpadding='10'>"; echo "<tr>"; if(empty($prodrow['image'])) { echo "<td><img src='./images.dummy.jpg' width='50' alt='" . $prodrow['name'] . "'></td>"; } else { echo "<td><img src=' ./images/" . $prodrow['image'] . "' width='50' alt='" . $prodrow['name'] . "'></td>"; } echo "<td>" . $prodrow['name'] ."</td>"; echo "<td>Select Quantity <select name='amountBox'>"; for($i=1;$i<=100;$i++) { echo "<option>" . $i . "</option>"; } echo "</select></td>"; echo "<td><strong>£" . sprintf('%.2f', $prodrow['price']) . "</strong></td>"; echo "<td><input type='submit' name='submit' value='Add to basket'></td>"; echo "</tr>"; echo "</table>"; echo "<form>"; } } require("footer.php"); ?> Hello everyone,
I run a small url shorting service.
I have bought the script and everything which short long urls. And i want to use a php code in one of the pages.
Let me explain you in detail first.
My site is https://786.pw and user goes there and enter the long url and the short url becomes something like https://786.pw/shorturl ( for example)
Now when this short url which is https://786.pw/shorturl is hit the user is redirected to the original long url. And thats how it is supposed to work.
But in between i have the option to show a splash page which can be a advertisement or a timer or anything "
The code of splash.php is :-
<?php defined("APP") or die() // Media Page ?> <?php include_once("analyticstracking.php") ?> <section> <div class="container splash"> <?php echo $this->ads(728,FALSE) ?> <div class="row"> <div class="col-md-4 thumb"> <div class="panel panel-dark panel-body"> <img src="<?php echo $url->short ?>/i"> </div> </div> <div class="col-md-8"> <div class="panel panel-default panel-body"> <h2> <?php if (!empty($url->meta_title)): ?> <?php echo $url->meta_title ?> <?php else: ?> <?php echo e("You are about to be redirected to another page.") ?> <?php endif ?> </h2> <p class="description"> <?php if (!empty($url->meta_description)): ?> <?php echo $url->meta_description ?> <?php endif ?> </p> <br> <div class="row"> <div class="col-sm-6"> <a href="<?php echo $this->config["url"] ?>/?r=<?php echo base64_encode($url->url) ?>" class="btn btn-primary btn-block redirect" rel="nofollow"><?php echo e("Redirect me"); ?></a> </div> <div class="col-sm-6"> <a href="<?php echo $this->config["url"] ?>" class="btn btn-default btn-block" rel="nofollow"><?php echo e("Take me to your homepage") ?></a></a> </div> </div> <hr> <p class="disclaimer"> <?php echo e("You are about to be redirected to another page. We are not responsible for the content of that page or the consequences it may have on you.") ?> </p> </div> </div> </div> </div> </section>Now, I want to add solve media php script in it. Which means any user who is using our url shortner service needs to complete the captcha before he can be finally directed to the destination url. The script supports solvemedia captcha solving. I spoke to the creator of this script and he told me this. "You will need to have some basic php knowledge to achieve this. |