PHP - Help With Thought Process!
This may spill over into java, just not quite sure yet!
Basically what I am trying to do, is fill a box with text, click a button which runs a function which send the text in the box via a JSON request to an external server. The JSON works fine, I just want a way of submitting the string which hopefully doesnt involve a form, but its the only way I can think of! Any other ideas? Similar TutorialsWas just wondering if anyone could help out with what should be a fairly simple fix for a contact form with image upload. The image DOES get uploaded to the temporary folder, but doesn't appear when I receive the email into my account. I think the form is almost good to go, just can't figure out why the image is not attatched to the email when i receive it - guessing the problem is somewhere in the last 10 lines of code. Really appreciate if someone could figure what's I'm doing wrong. (...perhaps it was thinking I could learn PHP in the first place!). Thanks. Code: [Select] <?php ini_set("sendmail_from", "darren@mywebsite.co.uk"); ini_set("SMTP", "smtp.myhostingcompany.co.uk"); if($name = filter_var($_POST['name'])) if($address = filter_var($_POST['address'])) if($postcode = filter_var($_POST['postcode'])) if($phone = filter_var($_POST['phone'])) if($email = filter_var($_POST['email'])) if($details = filter_var($_POST['details'])) if($contactby = filter_var($_POST['contactby'])) /* Subject and Email Destinations */ $emailSubject = 'Work Email!'; $webMaster = 'darren@mywebsite.co.uk'; /* Gathering Data Variables */ $nameField = $_POST['name']; $addressField = $_POST['address']; $postcodeField = $_POST['postcode']; $phoneField = $_POST['phone']; $emailField = $_POST['email']; $detailsField = $_POST['details']; $contactbyField = $_POST['contactby']; $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB) $upload_path = './uploads/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file <a href= "' . $upload_path . $filename . '" title="Your File">here</a>'; // It worked. else echo 'There was an error during the file upload. Please try again.'; // It failed $body = <<<EOD Name: $name Address: $address Postcode: $postcode Phone: $phone Email: $email Details: $details Contactby: $contactby EOD; $headers = "From: $email\r\n"; $headers .= "Contact-type: text/html\r\n"; $attachment = chunk_split(base64_encode(file_get_contents($temp_file))); $tmp_file = $_FILES['userfile']['tmp_name']; $success = mail($webMaster, $attatchment, $body, $headers, "-fdarren@mywebsite.co.uk"); /* Results rendered as HTML */ $theResults = <<<EOD SENT SENT SENT EOD; echo "$theResults" ?> Font tester - I thought I had it. Hi all I'm trying to produce this font tester where you can set a font with inputted text at a selected size. In my demo here http://www.ttmt.org.uk/test/ I can type in text and select the size. The image is set with the correct text and size but everything else is removed from the page. How can I do this so the image of the text appears below the form in the image tag. Code: [Select] <?php if(isset($_POST['submit'])){ // Set the content-type header('Content-Type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = $_POST['text']; $textSize = $_POST['size']; $font = 'corbelb.ttf'; // Add the text //imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagettftext($im, $textSize, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() $img = imagepng($im); imagedestroy($im); } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> </head> <body> <form action="index.php" method="post"> <input type="text" name="text" /> <select name="size"> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="18">18</option> <option value="24">24</option> <option value="30">30</option> <option value="36">36</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <img src="<?php echo $img; ?>" /> </body> </html> There is a sql query happening if the item is not empty, what I NEED and can not seem to figure out is to re run the rand() function. The server is PHP 4 so it is not possible to use the goto statement... That would be to easy. So any help would be great... Here is the code... the script running after the script finds a empty sql row is ot included... it works... just this one part does not. Code: [Select] <?php $connection = mysql_connect(CREDENTIALS REMOVED) or die(mysql_error()); mysql_select_db("testingblock", $connection)or die(mysql_error()); $random_num = rand(1,10); if($random_num == 1){ $query = sprintf("SELECT email FROM access_codes WHERE id='1'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 2){ $query = sprintf("SELECT email FROM access_codes WHERE id='2'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 3){ $query = sprintf("SELECT email FROM access_codes WHERE id='3'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 4){ $query = sprintf("SELECT email FROM access_codes WHERE id='4'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo '<br />'; if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 5){ $query = sprintf("SELECT email FROM access_codes WHERE id='5'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 6){ $query = sprintf("SELECT email FROM access_codes WHERE id='6'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if($random_num == 7){ $query = sprintf("SELECT email FROM access_codes WHERE id='7'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 8){ $query = sprintf("SELECT email FROM access_codes WHERE id='8'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 9){ $query = sprintf("SELECT email FROM access_codes WHERE id='9'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo '<br />'; if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } else if ($random_num == 10){ $query = sprintf("SELECT email FROM access_codes WHERE id='10'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); if(!empty($row['email'])){ header('Location: http://www.thestreetbeatint.com/Testing/blah.php'); } else { echo $recipient; } } ?> [icode] I put a snippet up yesterday, and thought it had been solved. It had a typo error, but there is still something wrong. The whole page follows, because it might be easier to see what I am doing. The form successfully inserts a new record OK, but it will not update a record that already exists as is intended. Instead, it always creates another new record. Where can I be wrong? <?php session_start(); // See if logged in member by checking session data if (isset($_SESSION['recid'])) { // Put stored session variables into local php variable $userid = $_SESSION['recid']; $username = $_SESSION['name']; $school = $_SESSION['college']; $payer_email = $_SESSION['payer_email']; $group1 = $_SESSION['group1']; $group2 = $_SESSION['group2']; $group3 = $_SESSION['group3']; $group4 = $_SESSION['group4']; $group5 = $_SESSION['group5']; $group6 = $_SESSION['group6']; } else { ?> <!-- make login box --> <html> <tr> <td> <p> <p> <p></td> </tr> <table style= border align="center" border="1" width="400" height="200"> <td align="center" valign="center">You need to<a href="login_allocate_quiz.php">log in</a>as an administrator to<br /> allocate quizzes to student groups.</td> </table> </html> <?php exit(); } // Set error message as blank upon arrival to page $errorMsg = ""; // Check to see if the form has been submitted if (isset($_POST['equip'])){ //Connect to the database through include include_once "demo_conn.php"; //set variables $equip = $_POST['equip']; $egroup1 = $_POST['egroup1']; $egroup2 = $_POST['egroup2']; $egroup3 = $_POST['egroup3']; $egroup4 = $_POST['egroup4']; $egroup5 = $_POST['egroup5']; $egroup6 = $_POST['egroup6']; //create variables to manipulate filenames in database $lowquip = strtolower($equip); $wordquip = str_replace (" ", "", $lowquip); $bigpic = $wordquip.'big'; $smallpic = $wordquip.'small'; $bigpic = $bigpic.'.jpg'; $smallpic = $smallpic.'.jpg'; $errorMsg = '<font size="-1"><u>ERROR:</u> You have not entered the following required information.'; $nogroup = ((!$egroup1) && (!$egroup2) && (!$egroup3) && (!$egroup4) && (!$egroup5) && (!$egroup6)); $noequip = (!$equip); if ($nogroup) {$errorMsg .= "--- Student Group. (No data was forwarded to the database.)</font>";} else if($noequip) {$errorMsg .= "--- Quiz Name. (No data was forwarded to the database.)</font>";} else {$query = mysql_query("SELECT equip FROM topics WHERE equip = '$equip' AND managerId = '$userid'"); if (mysql_num_rows($query) > 0) mysql_query("UPDATE topics SET egroup1 = '$egroup1', egroup2 = '$egroup2', egroup3 = '$egroup3', egroup4 = '$egroup4', egroup5 = '$egroup5', egroup6 = '$egroup6' WHERE equip = '$equip' AND managerId = '$userid'"); else mysql_query("INSERT INTO topics (managerId, equip, title, url_big, url_small, egroup1, egroup2, egroup3, egroup4, egroup5, egroup6) VALUES ('$userid','$wordquip', '$equip', '$bigpic', '$smallpic', '$egroup1', '$egroup2', '$egroup3', '$egroup4', '$egroup5', '$egroup6')") or die (mysql_error("error 1321")); $URL='make_quiz_list_test4.php'; header ('Location: '.$URL); } } ?> <!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" dir="ltr" lang="en-US" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="X-UA-Compatible" content="IE=4"> <!-- IE5 mode --> <meta http-equiv="X-UA-Compatible" content="IE=7.5"> <!-- IE7 mode --> <meta http-equiv="X-UA-Compatible" content="IE=100"> <!-- IE8 mode --> <meta http-equiv="X-UA-Compatible" content="IE=a"> <!-- IE5 mode --> <title>Manager selected quiz list</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]--> <script type="text/javascript" src="script.js"></script> </head> <body> <div id="art-page-background-simple-gradient"> <div id="art-page-background-gradient"></div> </div> <div id="art-main"> <div class="art-sheet"> <div class="art-sheet-tl"></div> <div class="art-sheet-tr"></div> <div class="art-sheet-bl"></div> <div class="art-sheet-br"></div> <div class="art-sheet-tc"></div> <div class="art-sheet-bc"></div> <div class="art-sheet-cl"></div> <div class="art-sheet-cr"></div> <div class="art-sheet-cc"></div> <div class="art-sheet-body"> <div class="art-header"> <div class="art-header-png"></div> <div class="art-header-jpeg"></div> <div class="art-logo"> <h1 id="name-text" class="art-logo-name"><a href="#">Safety Testing Online</a></h1> <div id="slogan-text" class="art-logo-text">Safety - The Most Valuable Insurance</div> </div> </div> <div class="art-nav"> <div class="l"></div> <div class="r"></div> <div class="art-nav-center"> <ul class="art-menu"> <li> <a href="../../index.php" class="active"><span class="l"></span><span class="r"></span><span class="t">Home</span></a> </li> <li> <a href="../demo_main.php"><span class="l"></span><span class="r"></span><span class="t">Demonstrations Page</span></a> <ul> </ul> </li> <li> <a href="logout.php"><span class="l"></span><span class="r"></span><span class="t">Admin Logout</span></a> </li> </ul> </div> </div> <div class="art-content-layout"> <div class="art-content-layout-row"> <div class="art-layout-cell art-content"> <div class="art-post"> <div class="art-post-tl"></div> <div class="art-post-tr"></div> <div class="art-post-bl"></div> <div class="art-post-br"></div> <div class="art-post-tc"></div> <div class="art-post-bc"></div> <div class="art-post-cl"></div> <div class="art-post-cr"></div> <div class="art-post-cc"></div> <div class="art-post-body"></div> <div class="art-post-bl"></div> <div class="art-post-br"></div> <div class="art-post-tc"></div> <div class="art-post-bc"></div> <div class="art-post-cl"></div> <div class="art-post-cr"></div> <div class="art-post-cc"></div> <div class="art-post-body"> <div class="art-post-inner art-article"> <table style="table-layout:fixed; width:850px;"> <tr> <td style="text-align:left; width:30px;"> </td> <td style="text-align:left; width:350px;"><font size="+1">Allocation of Woodwork Quizzes to Groups.</font></td> <td style="text-align:left; text-align:center; vertical-align:bottom; width:450px;"><font color="#0000FF">Administrator: <?php echo $username; ?> - <?php echo $school; ?>.</font></td> <td style="text-align:left; width:20px;"></td> </tr> </table> <table style="table-layout:fixed; width:850px;"> <tr> <td style="text-align:left; width:30px;"></td> <td style="text-align:left; vertical-align:bottom; width:800px;"><font color="#FF0000"><?php echo "$errorMsg"; ?></font></td> <td style="text-align:left; width:20px;"></td> </tr> </table> <table style="table-layout:fixed; border:thin; text-align:left; width:850px;"> <tr> <td style="text-align:right; width:35px;"></td> <td style="text-align:left; width:190px;"></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:left; width:210px;"><font color="#FF0000"></font></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:left; width:110px;"></td> <td style="text-align:right; width:20px;"></td> <td style="text-align:right; width:180px;"></td> <td style="text-align:right; width:35px;"></td> </tr> <hr/> <tr> <td rowspan="12"></td> <td rowspan="12"> <br/> <form method="post" enctype="multipart/form-data" action="make_quiz_list_test4.php"> <!--<form method="post" action="< ?php echo $PHP_SELF;?>">--> <select size="25" name="equip" /> <option selected value="">No Quiz Selected</option> <option value="Biscuit Jointer">Biscuit Jointer</option> <option value="Dowelling Machine">Dowelling Machine</option> <option value="Drill Cordless">Drill - Cordless</option> <option value="Drill with Cord">Drill - Power Corded</option> <option value="Pedestal Drill">Drill - Pedestal</option> <option value="Edge Tool Sharpener">Edge Tool Sharpener</option> <option value="General Workshop Safety">General Workshop Safety</option> <option value="Pedestal Grinder">Grinder - Pedestal</option> <option value="Hand Tools">Hand Tools</option> <option value="Jointer">Jointer (fixed)</option> <option value="Jointer Surfacer Combo">Jointer/Surfacer (combo)</option> <option value="Shaper">Shaper (fixed)</option> <option value="Lathe for Wood">Lathe - Wood</option> <option value="Linisher">Linisher</option> <option value="Mortiser with Hollow Chisel">Mortiser - Hollow Chisel</option> <option value="Nailgun for Brads">Nailer - Air (brads)</option> <option value="Planer Portable">Planer - (portable)</option> <option value="Router Portable">Router - Plunge</option> <option value="Router with Sliding Table">Router Table - Slide</option> <option value="Sander Belt">Sander - Belt (fixed)</option> <option value="Sander Disc Belt Combo">Sander - Belt/Disc Combo)</option> <option value="Sander Portable Belt">Sander - Belt (portable)</option> <option value="Sander Disc">Sander - Disc (fixed)</option> <option value="Sander Orbital">Sander - Orbital</option> <option value="Sander Random Orbit">Sander - Random Orbital</option> <option value="Sander Bobbin">Sander - Vertical Spindle</option> <option value="Saw Bandsaw">Saw - Bandsaw</option> <option value="Saw Bench">Saw - Circular (bench)</option> <option value="Saw Portable Circular">Saw - Circular (portable)</option> <option value="Saw Drop or Chop">Saw - Drop (alt Chop)</option> <option value="Saw Drop and Slide">Saw - Drop & Slide</option> <option value="Jigsaw Portable">Saw - Jigsaw (portable)</option> <option value="Saw Panel">Saw - Panel (fixed)</option> <option value="Saw Radial Arm">Saw - Radial Arm</option> <option value="Saw Sabre">Saw - Sabre(portable)</option> <option value="Saw Scroll">Saw - Scroll</option> <option value="Screw Driver Portable">Screwdriver - Portable</option> <option value="Thicknesser">Thickness Planer</option> </td> <td> </td> <td> </td> <td> </td> <td rowspan="7"><br /> <br /> <br /> <input type="checkbox" name="egroup1" value="1" /> <?php echo $group1; ?> <p> <input type="checkbox" name="egroup2" value="1" /> <?php echo $group2; ?> <p> <input type="checkbox" name="egroup3" value="1" /> <?php echo $group3; ?> <p> <input type="checkbox" name="egroup4" value="1" /> <?php echo $group4; ?> <p> <input type="checkbox" name="egroup5" value="1" /> <?php echo $group5; ?> <p> <input type="checkbox" name="egroup6" value="1" /> <?php echo $group6; ?> <p> <input type="submit" value="submit" name="Send Data"> </form> </td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td style="border:solid; color:#006600; 1px; padding:10px; text-align:left;"><font size="-1">Select a Quiz Topic from the drop down list on the left. Then go to the check boxes on the right to select all of the groups that are expected to undertake this test. <p>You can select only one quiz each time, but you can select from one to six groups to undertake that quiz. <p>Repeat this process until you have allocated all of the tests that you require each group to complete. <p>If you make a mistake you can delete a quiz allocation <a href="../../under_con.php">here</a> at any time. </font></td> <td></td> <td></td> <td style="color:#006600;"><font size="-1">Go back to the <br /> <a href="member_account.php">main edit page</a>.<br/> <br /> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </font></td> </tr> <tr> <td></td> <td> <br/> <br/> <br/> <br/></td> <td></td> <td></td> <td></td> </tr> </table> <!-- /article-content --> </div> <div class="cleared"></div> </div> <div class="cleared"></div> </div> </div> </div> </div> </div> <div class="cleared"></div> <div class="art-footer"> <div class="art-footer-inner"> <div class="art-footer-text"> <p><a href="#">Contact Us</a> | <a href="#">Terms of Use</a> | <a href="#">Trademarks</a> | <a href="#">Privacy Statement</a><br /> <?php $time = time () ; //This line gets the current time off the server $year= date("Y",$time); //This line formats it to display just the year echo "Copyright © 2010 - " . $year; //this line prints out the copyright date range, you need to edit 2010 to be your opening year ?> All Rights Reserved.</p> </div> </div> <div class="art-footer-background"></div> </div> <div class="cleared"></div> </div> </div> <div class="cleared"></div> <p class="art-page-footer">Designed by Frank.</p> </div> </body> </html> Does anyone know why this isn't working? $body = " Dear ".if ($row['customertitle'] != '') {echo $row['customertitle'].' '.$row['customerlastname'];} else (echo $row['customerfirstname'];}." <BR> This is a test. ".$_SERVER['SERVER_ADDR']." <BR> ".echo $accessinformation." "; Hi, very simple i'm sure... i have a code for a text box to pull info into from a mysql table. easy enough: Code: [Select] <?php echo "<input type=\"text\" id=\"b_info\" name=\"b_info\" value=\"$b_info\" style=\"width: 327px\" /text>"; ?> but suppose i dont just want a "line of text" i want one of those boxes with the scroll bar down the side (lol like the one im writing this in ) how do i change the above code to do it? i though doing this: Code: [Select] <?php echo "<input type=\"textarea\" id=\"b_info\" name=\"b_info\" value=\"$b_info\" style=\"width: 327px\" style=\"height: 185px\" /textarea>"; ?> would work, but obviously not, all ive done is make the box bigger easy workaround? Thanks I have been trying to figure out how this is done? One php file and all that changes is the name of the brand and the logo. This has to be clickable from a menu and also if a user changes the brand name it changes to the appropriate name and logo. Any ideas as to how this is done? If you can guide me in the right direction or give me an example of how this is done would be greatly appreciated. Thanks. http://www.drivermanager.com/en/download-confirmation.php?brand=compaq&logo= Hey guys, I've hit a huge obstacle in my coding process of a script I am writing. It is basically an uploading interface script and it works like this. I have files on my server and I want a user to click a button which fires a php script which in turn fires a bash script which IN TURN fires the uploading program (plowshare). So to make it simple: user logs in, sees upload button. Clicks it, file starts uploading. I then want the user to see "upload initiated" and that's it. The problem is that with what I have now, the script just won't finish loading until the file has been uploaded and as a matter of fact I don't even think it is uploading anything :S Here are the scripts: PHP interface to call the bash script: Code: [Select] <?php error_reporting(E_ALL); function run_in_background($Command, $Priority = 0) { if ($Priority) $PID = shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!"); else $PID = shell_exec("nohup $Command 2> /dev/null & echo $!"); return($PID); } function is_process_running($PID) { exec("ps $PID", $ProcessState); return(count($ProcessState) >= 2); } $file = $_GET['file']; // Location of file relative to the index $where = $_GET['where']; // Absolute index location $absolute = '/var/www/vhosts/animekyun.com/httpdocs/icarus/'; $where = $absolute . $where; //$outfile ='log'; echo $where . $file . '<br>'; echo "<h2>The upload has been initiated!</h2>"; $ps = run_in_background("/bin/sh uploadparser.sh $file $where > $outfile"); while(is_process_running($ps)) //echo $output; ?> Bash script to call uploading program: Code: [Select] #!/bin/sh { FILE=$1 WHERE=$2 FILENAME="/var/www/vhosts/animekyun.com/httpdocs/icarus/debug/debug_mu_$FILE" FILENAME2="/var/www/vhosts/animekyun.com/httpdocs/icarus/debug/debug_multi_$FILE" /usr/local/bin/plowup megaupload "$WHERE$FILE" >> "$FILENAME".txt 2>&1 /usr/local/bin/plowup multiupload "$WHERE$FILE" >> "$FILENAME2".txt 2>&1 } & this works fine when I pass the variables as arguments in CLI I hope i have been clear enough, it does seem rather confusing hi, is there a way to tell php to do a process again? example: Code: [Select] $draft_number=rand(1, 15); if($draft_number == 5){ START OVER AT TOP } else { $sql1 = "UPDATE names SET draft = '$draft_number' WHERE id = '$uid'"; $result1 = mysql_query($sql1) or die('Error, Check you fields and try again.'); } Hi guys, I want my application to run a triggered process based on time to execute some tasks, what is the best approach? Thanks I have a full working order form in PHP. I process it and display it with a process page called "process.php." Whenever this information is displayed on the web page "process.php" I also want it to send me an e-mail with all of the information that it just processed. i.e. Checked checkboxes, text entered, etc. Whenever I try to send the contents of "process.php" to an email $message = include 'process.php'; the process page just goes through an infinite loop displaying itself over and over again instead of sending itself in an email.
Edited by AP_King7, 20 August 2014 - 10:51 AM. I have this code: $shell = new COM('WScript.Shell'); $shell->Run("C:\WINDOWS\system32\cmd.exe /K ".$ini['indexer']['command'], 0, false); When it runs, it opens the command line, but then when it is done, it leaves the process open. How can I close it when the process is complete? i have a form for which the data is sent to a process page via jquery like so: Code: [Select] jQuery.post('<?php echo $this->site_root; ?>/modules/new_post_process.php',{ message:jQuery("#message_contents").val() } ,function(data) {etc... new_post_process checks the contents of message like so: if (empty($message) && empty($error)) { $is_error = true; $error = 'Please Enter A Message'; } the problem is that it always throws this message even when the textarea isnt empty. however after the error has appeared if i submit again it goes through fine. I suppressed the error and tried and the database gets populated with an empty value which means it is indeed empty. so why does it work on the second time around? I am using CKEditor for the textarea. everything else gets submitted normally but this textarea. heres the full code: the textarea: Code: [Select] <textarea cols="80" rows="10" id="message_contents"></textarea> Code: [Select] jQuery("#new_post_form").submit(function() { jQuery.post('<?php echo $this->site_root; ?>/modules/new_post_process.php',{ user_name:jQuery("#user_name").val(), redirect_url:jQuery("#redirect_url").val(), subject:jQuery("#subject_field").val(), forum_id:jQuery("#fid").val(), topic_id:jQuery("#tid").val(), method:jQuery("#method").val(), message:jQuery("#message_contents").val() } ,function(data) { if (data == 1) { jQuery("#process_info").removeClass().addClass("subject_okay").html("<img src=\"<?php echo $this->template_path; ?>icons/small_tick.png\" alt=\"icon\" />Redirecting...").fadeIn("slow"); var URL = jQuery("#redirect_url").val(); document.location = URL; } else { jQuery("#reply_btn").css("visibility", "visible"); jQuery("#draft_btn").css("visibility", "visible"); jQuery("#process_info").removeClass().addClass("subject_error").html('<img src="<?php echo $this->template_path; ?>icons/small_error.png" alt="icon" /> ' + data).fadeIn("slow"); } }); and the process page: if (isset($_POST['subject'])) { $message = $_POST['message']; if (empty($message) && empty($error)) { $is_error = true; $error = 'Please Enter A Message'; } if (empty($error) && $is_error == false) { $query = $link->prepare("INSERT INTO ".TBL_PREFIX."posts (p_fid, p_tid, p_poster, p_name, p_content, p_time_posted) VALUES ('$forum_id', '$topic_id', '$user_name', '$subject', '$message', '".$config['time_now']."') ") or die(print_link_error()); echo "1"; } else { echo $error.'-'.$message; } this retrieves data from a webservice at Library of Congress for example this here http://www.loc.gov/standards/sru/simple.html What I want to do is process the XML? into a string of usable text to put in a mysql database Am I getting XML back or what? save it and run it to see. In firefox, it shows xml headers, in chrome just the text elements. <?PHP //from here http://www.devshed.com/c/a/PHP/Fetching-Search-Results-as-Serialized-Arrays-with-Yahoo-Web-Services-and-PHP-5/1/ //http://php.net/manual/en/book.simplexml.php // example using LOC SRU Search Web Service - search results are displayed in raw XML format try{ $request='http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5'; // trigger the http request if(!$results=file_get_contents($request)){throw new Exception('Error requesting LOC SRU Web service');} // display the results in XML format header('Content-type:text/xml;charset=iso-8859-1'); echo $results; }//end of try catch(Exception $e){echo $e->getMessage();exit();} $xml = simplexml_load_string($result); print_r($xml); //print_r ($xmlarray); ?> Hi all, Newb here with a few months of PHP experience. I'm working on a project where if a web user signs up for a 30-day trial, they need to be notified near the end of that trial--let's say 25 days--that the trial is expiring. So I need some kind of batch process that runs in the background, perhaps every night at 1am, that looks at the signup date for all trial users and compares that date to the current date. If the difference is 5 days, then that user should be sent an email. Does anyone know how to set up a nightly batch process that like this? I'm not concerned so much with the date comparison as I am with getting a daily process to run in the background. Coldfusion has something called a Scheduled Task, but being new to PHP, I don't know what would be comparable. Any help welcome! Thanks... Hi all,
I am building a website for my local motorclub.
we are wanting to start taking online payments for membership and events. I have built a members only area - the way to get access is for a member of staff to accept the registration. this is all fine for members who pay via cheque or simular.
I am wanting a sign up process to include the payment page, was going to use paypal as the merchant. So if people want to join the club they are able to do so and get immediate access to the members only page instead of waiting for staff to check if the payment has cleared then set up there account etc.
so basically i need a sign-up form (which is done) then a purchase button at the bottom, which takes the payment and then redirects to the website but 'tells my website the payment has been taken and to give full access'.
I cant really explain how i want it, but i hope you understand from what i have said.
With the following code
<?php ?> There is still an error output of syntax error on line 11, please help, what's wrong with my code This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=355947.0 hi there, I have a chained combo boxes. I manage to get the values for the sub process using onchange event.My problem here is how can I retain the values in the sub process combo box after the page is loaded? main.php Code: [Select] <?php require_once 'connectDB.php'; $sub_id = $_GET['sub_id']; $id = $_SESSION['process_id']; $sql = " SELECT * FROM tb_process ORDER BY pro_id ASC"; $result = mysql_query($sql) or die(mysql_error()); $sql = "SELECT tb_record.rec_tpcd, tb_record.rec_part, tb_record.rec_code, tb_record.rec_vendor, tb_record.rec_location, tb_record.rec_remark, tb_sub_process.sub_name, tb_process.pro_name FROM tb_record LEFT JOIN tb_sub_process ON tb_record.sub_id=tb_sub_process.sub_id LEFT JOIN tb_process ON tb_sub_process.pro_id=tb_process.pro_id WHERE tb_sub_process.sub_id = '$sub_id'"; $result2 = mysql_query($sql); $row = mysql_fetch_assoc($result2); $pro_name = $row['pro_name']; $sub_name = $row['sub_name']; ?> <html> <head> <script type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript" src="js/jquery-1.2.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#selectProcess").change(function() { var processID = $(this).val(); if(processID > 0) { $("#txtID").val(processID); $("#selectSubProcess").load('getSub.php?processID='+processID); } }); $("#selectSubProcess").change(function() { var subProcessID = $(this).val(); if(subProcessID > 0) { window.location = 'main.php?sub_id='+subProcessID; } }); }); </script> </head> <body> <form action="" method="post"> <table> <tr> <td>Process: </td> <td> <select id="selectProcess" name="selectProcess"> <option value="0" selected="selected">---SELECT PROCESS---</option> <?php while ($row = mysql_fetch_array($result)) { $process_id = $row['pro_id']; $process_name = $row['pro_name']; $select = ($id == $process_id) ? 'selected="selected"' : NULL; echo "<option value='$process_id' $select>$process_name</option>"; } ?> </select> </td> </tr> <tr> <td>Sub Process: </td> <td> <select id="selectSubProcess" name="selectSubProcess" > <option>SELECT PROCESS FIRST</option> </select> </td> </tr> </table> </form> <table border=1> <?php while($row = mysql_fetch_assoc($result2)) { extract($row); $imageDir1="images/".$rec_tpcd.".jpg"; $info = @getimagesize($imageDir1); if((bool)$info) { $imageDir="images/".$rec_tpcd.".jpg"; } else { $imageDir="images/NoPhoto.jpg"; } if ($col == 0) { $display .= "<tr>"; } $col++; if ($col == 1) { $col = 0; $display .= "</td>"; } echo "<tr> <td> <img src=$imageDir width='220' height='170' onClick=\"window.open('$imageDir', 'popup','height=500,width=800,scrollbars=yes,resizeable=yes status=yes'); return false\" target=\"_blank\"> </td> <td> <table style='overflow:auto; width:325px;'> <tr> <td width='80' valign='top'>Name</td> <td valign='top'>:</td> <td valign='top' colspan='2'>$rec_part</td> </tr> <tr> <td valign='top'>Code</td> <td valign='top'>:</td> <td valign='top' colspan='2'>$rec_code</td> </tr> <tr> <td>TPCD</td> <td>:</td> <td colspan='2'>$rec_tpcd</td> </tr> <tr class='style15'> <td>Vendor</td> <td>:</td> <td colspan='2'>$rec_vendor</td> </tr> <tr> <td>Location</td> <td>:</td> <td colspan='2'>$rec_location</td> </tr> <tr> <td>Remarks</td> <td>:</td> <td>$rec_remark</td> <td align='right'> <input type='image' name='change[$rec_tpcd]' src='library/cart add.png' width='20' height='20' value='Add To Order List >'/> </td> </tr> </table> </td> </tr>"; } ?> </table> </body> </html> getSub.php Code: [Select] <?php require_once 'connectDB.php'; if(isset($_GET['processID'])) { $process_id = $_GET['processID']; $sql = " SELECT * FROM tb_sub_process WHERE pro_id = '$process_id' ORDER BY sub_id ASC"; $result = mysql_query($sql) or die(mysql_error()); $_SESSION['process_id'] = $process_id; echo "<option>---------------------SELECTION--------------------</option>"; while($row = mysql_fetch_assoc($result)) { $sub_process_id = strtoupper($row['sub_id']); $sub_process_name = strtoupper($row['sub_name']); echo "<option value='$sub_process_id'>$sub_process_name</option>"; } } ?> I have this 3 tables
users (id_user)
music_styles (id_style, style) ex. (1) - (Blues)
user_styles (id_user, id_style)
I'm trying to create a form in which the user ($user = $_SESSION['id_user']) chooses through a multiple select the styles of preference to store them in the database using mysqli statements.
If the styles prefered are selected they should be displayed in the select input later, how can i accomplish this?
Thanks.
|