Jump to content

jason360

Members
  • Posts

    77
  • Joined

  • Last visited

Everything posted by jason360

  1. Hey Guys, Stuck on building an array that I am using for Paypal. I want to build an array named $product_id_array to send on a single input value to paypal or all my individual id's and quantities. I have done various combinations with no luck. The product id is $id and the quantity is $value, I want to create an array of all for each item/id. The ids and quantities to be in the format "id-quantity," with commas and dashes (ex. 3-1, 5-2, 3-1). I have tried various things but the array isn't working. I am a noob so any help is appreciated. function paypal_items() { $num = 0; foreach($_SESSION as $name => $value) { if($value!=0) { if(substr($name, 0 , 5)=='cart_') { $id = substr($name, 5, strlen($name)-5); $get = mysql_query('SELECT id, name, price, shipping FROM products WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)) { $num++; echo '<input type="hidden" name="item_number_'.$num.'" value="'.$id.'">'; echo '<input type="hidden" name="item_name_'.$num.'" value="'.$get_row['name'].'">'; echo '<input type="hidden" name="amount_'.$num.'" value="'.$get_row['price'].'">'; echo '<input type="hidden" name="shipping_'.$num.'" value="'.$get_row['shipping'].'">'; echo '<input type="hidden" name="shipping2_'.$num.'" value="'.$get_row['shipping'].'">'; echo '<input type="hidden" name="quantity_'.$num.'" value="'.$value.'">'; } } } } } //product id array start $product_id_array = ''; $i = 0; foreach($_SESSION as $name => $value) { $id = substr($name, 5, strlen($name)-5); $product_id_array .= "$id-".$value.","; } //product id array end Then send via form to Paypal: <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" > <input type="hidden" name="custom" value="<?php echo $product_id_array?>"> <?php paypal_items(); ?> </form>
  2. Hey guys, Just wondering if anyone can help me with my submit form. I can`t get the error message to work. After trying a bunch of different things it still wont work. The login works fine, but when I put in a bad email or password it doesn`t show the error message and just forwards through to the header link. Any help would be appreciated. Thanks. if($_POST['submit']=='Login') { // Checking whether the Login form has been submitted $err = array(); // Will hold our errors if(!$_POST['username'] || !$_POST['password']) $err[] = 'All the fields must be filled in!'; if(!count($err)) { $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['password'] = mysql_real_escape_string($_POST['password']); $_POST['rememberMe'] = (int)$_POST['rememberMe']; // Escaping all input data $row = mysql_fetch_assoc(mysql_query("SELECT user_id,usr,first FROM wk_members WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'")); if($row['usr']) { // If everything is OK login $loginok = TRUE; if ($loginok==TRUE) { if ($_POST['rememberMe']=="1") { setcookie('usr', $row['usr'], time()+5184000, '/'); setcookie('user_id', $row['user_id'], time()+5184000, '/'); setcookie('first', $row['first'], time()+5184000, '/'); setcookie('rememberMe', $row['rememberMe'], time()+5184000, '/'); } else if ($_POST['rememberMe']=="") { $_SESSION['usr']=$row['usr']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['first']=$row['first']; $_SESSION['rememberMe'] = $_POST['rememberMe']; } } } else $err[]='Wrong username and/or password!'; $loginok = FALSE; } if($err) $_SESSION['msg']['login-err'] = implode('<br />',$err); // Save the error messages in the session header('Location: http://mysite.com''); exit(); } $script = ''; ?> <!-- form start --> <form action="" method="post" class="reg-form" onsubmit="return formCheck(this);"> <p class="formMsg"> <?php if($_SESSION['msg']['login-err']) { echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>'; unset($_SESSION['msg']['login-err']); } ?> <p> <fieldset> <input class="" type="text" name="username" id="username" value="" size="23" placeholder="Your Email" /> <input class="" type="password" name="password" id="password" value="" size="23" placeholder="Your Password" /> <label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> <p class="formMsg">Remember me</p></label> <div class="submit-button"> <input type="submit" name="submit" value="Login" class="" /> </div> </fieldset> </form>
  3. Hey guys, For some reason my login page error messages will not work. It works on a different page, but not on this one. After hours of trouble shooting, I can't figure out what I am doing wrong. Any help would be appreciated. Its just a standard login page. Thanks, JK <?php if($_POST['submit']=='Login') { // Checking whether the Login form has been submitted $err = array(); // Will hold our errors if(!$_POST['username'] || !$_POST['password']) $err[] = 'All the fields must be filled in!'; if(!count($err)) { $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['password'] = mysql_real_escape_string($_POST['password']); $_POST['rememberMe'] = (int)$_POST['rememberMe']; // Escaping all input data $row = mysql_fetch_assoc(mysql_query("SELECT user_id,usr,first FROM wk_members WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'")); if($row['usr']) { // If everything is OK login $loginok = TRUE; if ($loginok==TRUE) { if ($_POST['rememberMe']=="1") { setcookie('usr', $row['usr'], time()+5184000, '/'); setcookie('user_id', $row['user_id'], time()+5184000, '/'); setcookie('first', $row['first'], time()+5184000, '/'); setcookie('rememberMe', $row['rememberMe'], time()+5184000, '/'); } else if ($_POST['rememberMe']=="") { $_SESSION['usr']=$row['usr']; $_SESSION['user_id'] = $row['user_id']; $_SESSION['first']=$row['first']; $_SESSION['rememberMe'] = $_POST['rememberMe']; } } } else $err[]='Wrong username and/or password!'; $loginok = FALSE; } if($err) $_SESSION['msg']['login-err'] = implode('<br />',$err); // Save the error messages in the session header('Location: http://www.mysite.com'); exit(); } $script = ''; ?> <form action="" method="post" class="reg-form" onsubmit="return formCheck(this);"> <?php if($_SESSION['msg']['login-err']) { echo '<div class="err">'.$_SESSION['msg']['login-err'].'</div>'; unset($_SESSION['msg']['login-err']); } ?> <fieldset> <input class="" type="text" name="username" id="username" value="" size="23" placeholder="Your Email" /> <input class="" type="password" name="password" id="password" value="" size="23" placeholder="Your Password" /> <label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> Remember me</label> <div class="submit-button"> <input type="submit" name="submit" value="Login" class="" /> </div> </fieldset> </form>
  4. This worked: if(isset($_COOKIE['user_id'])) { $_SESSION['user_id'] = $_COOKIE['user_id']; }
  5. Hey guys, Any idea how to add a cookie to this string? $_COOKIE['first'] Thanks <?php echo $_SESSION['first'] ? $_SESSION['first']: 'Guest';?>
  6. Just in addition to the above: Would including cookies to this statement: if(!$_SESSION['user_id']): be done like this?: if((!$_SESSION['user_id'])||(!$_COOKIE['user_id'])):
  7. Hey guys, I have a login system that welcomes the user with their first name. The system is working however it will not display the name when I log in with cookies, however the print_r array for cookies is showing that the 'first' name is working. I am hacking away trial and error but not sure how to do this. I tried various combos. My cookie is $COOKIE['first'] My code is as follows: <div class="tab"> <ul class="login"> <li class="left"> </li> <li>Hello <?php echo $_SESSION['first'] ? $_SESSION['first']: 'Guest';?>!</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#"><?php echo $_SESSION['user_id']?'Open Panel':'Log In | Register';?></a> <a id="close" style="display: none;" class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> </div> <!-- / top --> Thanks again! JK
  8. Thanks guys...rebuilt my cookies and sessions.
  9. Hey guys, I have a website that is using a login. I want add a shopping cart to the site in a separate folder (mysite.com/cart). I want the user to be able to say signed in for a couple weeks without having to re login so I am using: session_set_cookie_params(2*7*24*60*60, '/'); I am using sessions for my cart. The existing settings works fine with cart however the cart is holding the items for the length of the two week cookie params, and I want the cart to be reset when the window is closed, but still logged in. I have never used sessions before and logins. Is it possible to use different params or should i be using some kind of unset function? I am really not sure the best way to go about this. I don't want the user to have to login separately when they use the cart. Any ideas on the best way to do this would be appreciated. Please note i am a bit of a programming noob. Thanks, JK My cart script: mysite.com/cart/cart.php include("../config.inc.php"); session_name('wkLogin'); session_set_cookie_params(0); session_start(); if (isset($_GET['add'])) { $quantity = mysql_query('SELECT id, quantity FROM products WHERE id='.mysql_real_escape_string((int)$_GET['add']).''); while ($quantity_row = mysql_fetch_assoc($quantity)){ if ($quantity_row['quantity']!=$_SESSION['cart_'.(int)$_GET['add']]) { $_SESSION['cart_'.(int)$_GET['add']]+='1'; } } header('location: http://www.mysite.com/cart/view.php?pid='.$_GET['add'].''); } function cart() { foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0 , 5) =='cart_') { $id = substr($name, 5, (strlen($name) -5)); $get = mysql_query ('SELECT id, name, price FROM products WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)) { $sub = $get_row['price']*$value; } } $total += $sub; } } if ($total==0) { echo "Your cart is empty."; } else { echo '<p>Total: &#36;'.number_format($total, 2).'</p>'; } } My cart view item page: mysite.com/cart/view.php?pid=2 define('INCLUDE_CHECK',true); require('../config.inc.php'); require('../functions.php'); require('../cart/cart.php'); require '../login.php'; // initialization $result_array = array(); $counter = 0; $pid = ($_GET['pid']); // Full Size View of Photo if( $pid ) { $result = mysql_query( "SELECT * FROM products WHERE id='".addslashes($pid)."'" ); list($id, $name, $description, $snippet, $link, $price, $shipping, $quantity, $anchor) = mysql_fetch_array( $result ); $nr = mysql_num_rows( $result ); mysql_free_result( $result ); } ....... My login page: mysite.com/index.php define('INCLUDE_CHECK',true); require "connect.php"; require 'functions.php'; // Those two files can be included only if INCLUDE_CHECK is defined session_name('wkLogin'); // Starting the session session_set_cookie_params(2*7*24*60*60, '/'); // Making the cookie live for 2 weeks session_start(); require 'login.php';
  10. Thanks for the suggestion N1. I found my issue. My cart.php code was losing the get id in redirect. Problem solved.
  11. Hey guys, This is probably simple but I can't figure out what I am doing wrong. I am trying to get this $page to redirect to a dynamic page using the id. This code I am using for $page ='../shop/product.php?pid='.$id.''; is coming up blank for the id. Any help is appreciated. Thanks JK define('INCLUDE_CHECK',true); require('../config.inc.php'); require('../functions.php'); // initialization $result_array = array(); $counter = 0; $pid = ($_GET['pid']); // Full Size View of Photo if( $pid ) { $result = mysql_query( "SELECT * FROM products WHERE id='".addslashes($pid)."'" ); list($id, $name, $description, $snippet, $link, $price, $shipping, $quantity, $anchor) = mysql_fetch_array( $result ); $nr = mysql_num_rows( $result ); mysql_free_result( $result ); } // cart php $page ='../shop/product.php?pid='.$id.''; require('../shop/cart.php');
  12. Hey guys, Just building a site using php. I would like to know how to create pages without having to make ".php" links for every page. For example I want to build the site to be as follows: www.mysite.com/products instead of www.mysite.com/products.php. (Further example www.mysite.com/products/headphones ) An example of what I am looking for is as follows: http://www.starbucks.ca/store-locator Any idea how starbucks is doing this? It isn't making a separate folder and index for every page is it? Thanks in advance! Jason
  13. Hey guys, bit of a newb here. But I am having a brutal time trying to get the php mail() function to work with GoDaddy. I contacted them and they said I must use their PHP gdform.php script to send out emails. My script sends the emails from register.php and functions.php. Does anyone know how I can integrate godaddy's gdform.php to work with my functions.php mail() script. Doesn't make sense to me my go daddy makes this so difficult to use a simple function. Thanks in advance!!! My register.php script <?php include ('config.inc.php'); include ('functions.php'); // Those two files can be included only if INCLUDE_CHECK is defined session_name('wkLogin'); // Starting the session session_set_cookie_params(2*7*24*60*60); // Making the cookie live for 2 weeks session_start(); if($_SESSION['id'] && !isset($_COOKIE['wkRemember']) && !$_SESSION['rememberMe']) { // If you are logged in, but you don't have the wkRemember cookie (browser restart) // and you have not checked the rememberMe checkbox: $_SESSION = array(); session_destroy(); // Destroy the session } if(isset($_GET['logoff'])) { $_SESSION = array(); session_destroy(); header("Location: tester.php"); exit; } if($_POST['submit']=='Login') { // Checking whether the Login form has been submitted $err = array(); // Will hold our errors if(!$_POST['username'] || !$_POST['password']) $err[] = 'All the fields must be filled in!'; if(!count($err)) { $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['password'] = mysql_real_escape_string($_POST['password']); $_POST['rememberMe'] = (int)$_POST['rememberMe']; // Escaping all input data $row = mysql_fetch_assoc(mysql_query("SELECT id,usr FROM wk_members WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'")); if($row['usr']) { // If everything is OK login $_SESSION['usr']=$row['usr']; $_SESSION['id'] = $row['id']; $_SESSION['rememberMe'] = $_POST['rememberMe']; // Store some data in the session setcookie('wkRemember',$_POST['rememberMe']); } else $err[]='Wrong username and/or password!'; } if($err) $_SESSION['msg']['login-err'] = implode('<br />',$err); // Save the error messages in the session header("Location: tester.php"); exit; } else if($_POST['submit']=='Register') { // If the Register form has been submitted $err = array(); if(strlen($_POST['username'])<4 || strlen($_POST['username'])>32) { $err[]='Your username must be between 3 and 32 characters!'; } if(preg_match('/[^a-z0-9\-\_\.\@]+/i',$_POST['username'])) { $err[]='Your username contains invalid characters!'; } if(!checkEmail($_POST['email'])) { $err[]='Your email is not valid!'; } if(!count($err)) { // If there are no errors $pass = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6); // Generate a random password $_POST['email'] = mysql_real_escape_string($_POST['email']); $_POST['username'] = mysql_real_escape_string($_POST['username']); // Escape the input data mysql_query(" INSERT INTO wk_members(usr,pass,email,regIP,dt) VALUES( '".$_POST['username']."', '".md5($pass)."', '".$_POST['email']."', '".$_SERVER['REMOTE_ADDR']."', NOW() )"); if(mysql_affected_rows($link)==1) { send_mail( 'noreply@mygodaddydomain.com', $_POST['email'], 'Registration System Demo - Your New Password', 'Your password is: '.$pass); $_SESSION['msg']['reg-success']='We sent you an email with your new password!'; } else $err[]='This username is already taken!'; } if(count($err)) { $_SESSION['msg']['reg-err'] = implode('<br />',$err); } header("Location: tester.php"); exit; } $script = ''; if($_SESSION['msg']) { // The script below shows the sliding panel on page load $script = ' <script type="text/javascript"> $(function(){ $("div#panel").show(); $("#toggle a").toggle(); }); </script>'; } ?> My Mail() funtions.php script <?php function checkEmail($str) { return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str); } function send_mail($from,$to,$subject,$body) { $headers = ''; $headers .= "From: $from\n"; $headers .= "Reply-to: $from\n"; $headers .= "Return-Path: $from\n"; $headers .= "Message-ID: <" . md5(uniqid(time())) . "@" . $_SERVER['SERVER_NAME'] . ">\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Date: " . date('r', time()) . "\n"; mail($to,$subject,$body,$headers); } ?> Godaddys gdform.php <?php $request_method = $_SERVER["REQUEST_METHOD"]; if($request_method == "GET") { $query_vars = $_GET; } elseif ($request_method == "POST") { $query_vars = $_POST; } reset($query_vars); $t = date("U"); $file = $_SERVER['DOCUMENT_ROOT'] . "\ssfm\gdform_" . $t; $fp = fopen($file,"w"); while (list ($key, $val) = each ($query_vars)) { fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\r\n"); fputs($fp,"$val\r\n"); fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\r\n"); if ($key == "redirect") { $landing_page = $val; } } fclose($fp); if ($landing_page != "") { header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page"); } else { header("Location: http://".$_SERVER["HTTP_HOST"]."/"); } ?> Just a basic email test gives me this error: Warning: mail() [function.mail]: Failed to connect to mailserver at "relay-hosting.secureserver.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\hosting\7746358\html\testmail.php on line 7 Mail Sent. mailtest.php <?php $to = "someone@domain.com"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "noreply@mygodaddydomain.com"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?>
  14. Anybody know a good mobile website redirect function? Cant find a good one. Thanks in advance! Jason
  15. Thanks alot guys!!!! Works great!! 8)
  16. Hey guys, I am using php loop to echo out all off the data in my database category within a html table. However I would like to reduce each table row to only 5 results then start a new row so that the table fits within the webpage. Any suggestions? Any help is much appreciated. Thanks. Jason Here is what i am using, but does not fit within the page. <table cellspacing="10"> <tr> <?php $query = mysql_query('SELECT photo_id, photo_name FROM gallery_photos WHERE photo_category = "Books" AND photo_approved = 1 ORDER BY rand()'); while ($row = mysql_fetch_array($query)) { echo "<td><a href='http://www.mysite.com/view.php?pid=".$row['photo_id']."'><img src='photos/".$row['photo_id'].".jpg' width='115' height='115' /><center><h3><b>".$row['photo_name']."</b></h3></center></a></td>"; } ?> </tr> </table>
  17. Hey guys, I am a newb but trying to figure out how I can upload multiple associated photo files. My code is working for one photo, however I would like to have multiple photos that are associated uploaded at the same time. I would like the photos save in a format such as: photo_filename1 = 100, photo_filename2 = 100_a I am using the following code with no luck, not sure how I can work this. Any help is much appreciated!!! Thanks in advance. <code> <?php include("config.inc.php"); // initialization $result_final = ""; $counter = 0; // List of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); // GD Function List $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); // Fetch the photo array sent by preupload.php $photos_uploaded1 = $_FILES['photo_filename1']; $photos_uploaded2 = $_FILES['photo_filename2']; // Fetch the photo caption array $photo_caption = $_POST['photo_caption']; while( $counter <= count($photos_uploaded1) ) { if($photos_uploaded1['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded1['type'][$counter], $known_photo_types)) { $result_final .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos(`photo_filename1`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" ); $new_id = mysql_insert_id(); $filetype = $photos_uploaded1['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id.".".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename1='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file copy($photos_uploaded1['tmp_name'][$counter], $images_dir."/".$filename); // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } // Build Thumbnail with GD 1.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; // Read the source file $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { // Let's create an blank image for the thumbnail $destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height ); // Now we resize it ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ); } // Let's save the thumbnail $function_to_write( $destination_handle, $images_dir."/tb_".$filename ); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />"; } } $counter++; } //file2 while( $counter <= count($photos_uploaded2) ) { if($photos_uploaded2['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded2['type'][$counter], $known_photo_types)) { $result_final2 .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos(`photo_filename2`) VALUES('0')" ); $new_id = mysql_insert_id(); $filetype = $photos_uploaded2['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id."_1.".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename2='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file copy($photos_uploaded2['tmp_name'][$counter], $images_dir."/".$filename); $result_final2 .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />"; } } $counter++; } // Print Result echo <<<__HTML_END <html> <head> <title>Photos uploaded</title> </head> <body> $result_final $result_final2 </body> </html> __HTML_END; ?> </code>
  18. I am wondering if it is because the arrays are not matched up: Webpage upload form(works correct) response: Array ( [category] => 1 [photo_caption] => Array ( [0] => text ) [photo_details] => Array ( [0] => text ) [photo_story] => Array ( [0] => text ) [photo_email] => Array ( [0] => text ) [submit] => Add Photos ) Array ( [0] => text ) Array ( [0] => text ) Phonegap upload response: Array ( [photo_caption] => Text [photo_details] => text [photo_email] => text [photo_story] =>text)
  19. Yes, it is all of them. I printed the variables: print_r($photo_caption1); < /br> print_r($photo_details1); The response was successful, the full text made it through. Response: Text < /br> text This is very strange...could the problem be on the mysql side? Note when i use the webpage upload form (this work correctly): I get this response from print_r($_POST): Array ( [category] => 1 [photo_caption] => Array ( [0] => text ) [photo_details] => Array ( [0] => text ) [photo_story] => Array ( [0] => text ) [photo_email] => Array ( [0] => text ) [submit] => Add Photos ) Array ( [0] => text ) Array ( [0] => text ) <?php include("config.inc.php"); // initialization $photo_upload_fields = ""; $counter = 1; // default number of fields $number_of_fields = 1; // If you want more fields, then the call to this page should be like, // preupload.php?number_of_fields=20 if( $_GET['number_of_fields'] ) $number_of_fields = (int)($_GET['number_of_fields']); // Firstly Lets build the Category List $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" ); while( $row = mysql_fetch_array( $result ) ) { $photo_category_list .=<<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); // Lets build the Photo Uploading fields while( $counter <= $number_of_fields ) { $photo_upload_fields .=<<<__HTML_END <tr> <td> Photo: <input name=' photo_filename[]' type='file' /> </td> </tr> <tr> <td> Title: <br> <textarea name='photo_caption[]' cols='30' rows='1'></textarea> <br> Details: <br> <textarea name='photo_details[]' cols='100' rows='2'></textarea> <br> Story: <br> <textarea name='photo_story[]' cols='100' rows='10'></textarea> <br> Email: <br> <textarea name='photo_email[]' cols='100' rows='1'></textarea> <br> </td> </tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <html> <head> <title>Lets upload Photos</title> </head> <body> <form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'> <table width='90%' border='0' align='center' style='width: 90%;'> <tr> <td> Select Category <select name='category'> $photo_category_list </select> </td> </tr> <tr> <td> <p> </p> </td> </tr> <!-Insert the photo fields here --> $photo_upload_fields <tr> <td> <input type='submit' name='submit' value='Add Photos' /> </td> </tr> </table> </form> </body> </html> __HTML_END; ?>
  20. No problem, here it is (note using jqtouch, jquery, phonegap); Here is my upload from: [script] var options = new FileUploadOptions(); options.fileKey="photo_filename[]"; options.fileName= "file.jpg"; //options.mimeType="image/jpeg"; var params = new Object(); params.photo_caption = document.getElementById("value1").value; params.photo_details = document.getElementById("value2").value; options.params = params; var ft = new FileTransfer(); ft.upload(imageURI, "http://www.mysite.com/upload.php", win, fail, options); [/script] [html] <form> <ul class="edit rounded"> <li><textarea name="photo_caption" id="value1" placeholder="Title - *Required*" /></textarea></li> <li><input type="text" name="photo_details" id="value2" placeholder="Details" /></li> <li class="arrow"><a href="#" onclick="getPhoto(pictureSource.PHOTOLIBRARY);"><h1>Submit Photo</h1></a></li> </ul> <img style="display:none;width:60px;height:60px;" id="smallImage" src="" /> <img style="display:none;" id="largeImage" src="" /> </div> </form> [/html] Here is my server/php side: <?php include("config.inc.php"); // initialization $result_final = ""; $counter = 0; // List of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); // GD Function List $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); // Fetch the photo array sent by preupload.php print_r($_POST); $photos_uploaded = $_FILES['photo_filename']; // Fetch the photo caption array $photo_caption1 = $_POST['photo_caption']; $photo_details1 = $_POST['photo_details']; $photo_story1 = $_POST['photo_story']; $photo_email = $_POST['photo_email']; // Swear filter1 function censor ($string) { if ($string) { // array of swear words and replacements $sweararray = array("ahole","anus","ash0le","ash0les","asholes","ass","assh0le","assh0lez","asshole","assholes","assholz","asswipe","azzhole","bassterds","bastard","bastards","bastardz","basterds","basterdz","Biatch","bitch","bithes","Blow Job","boffing","butthole","buttwipe","c0ck","c0cks","c0k","cawk","cawks","Clit","cnts","cntz","cock","cokhead","cock-head","cocks","CockSucker","cock-sucker","crap","cum","cunt","cunts","cuntz","dick","dild0","dild0s","dildo","dildos","dilld0","dilld0s","doinatricks","dominatrics","dominatrix","dyke","enema","f u c k","f u c k e r","fag","fag1t","faget","fagg1t","faggit","faggot","fagit","fags","fagz","faig","faigs","fart","flipping the ird","fuck","fucker","fuckin","fucking","fucks","Fudge Packer","fuk","Fukah","Fuken","fuker","Fukin","Fukk","Fukkah","Fukken","Fukker","Fukkin","g00k","gay","gayboy","gays","gayz","h00r","h0ar","h0re","gook","hell","hoar","hoor","hoore","jackoff","jap","jerk-ff","jisim","jiss","jizm","jizz","knob","knobs","knobz","kunt","kunts","kuntz","Lesbian","Lezzian","Lipshit","Lipshitz","masochist","masokist","massterbait","masstrbait","masstrbate","masterbaiter","masterbat","masterbates","Motha Fucker","n1gr","nastt","nigger","nigur","niiger","niigr","orafis","orgasim","orgasm","orgasum","oriface","orifice","orifiss","packi","packie","packy","paki","pakie","paky","pecker","peeenus","peeenusss","peens","peinus","pen1s","penas","penis","penus","penuus","Phuc","Phuck","Phuk","Phuker","Phukker","polc","polack","polak","Poonani","pr1c","pr1ck","pr1k","pusse","pussee","pussy","puuke","puuker","queer","queers","queerz","qweers","qweerz","qweir","recktum","rectum","retard","sadist","scank","schlong","crewing","semen","sex","sexy","Sh!t","sh1t","sh1ter","sh1ts","sh1tter","sh1tz","shit","shits","shitter","Sitty","Shity","shitz","Shyt","Shyte","Shytty","Shyty","skanck","skank","skankee","skankey","skanks","Skaky","slut","sluts","Slutty","slutz","tit","turd","va1jina","vag1na","vagiina","vagina","vaj1na","vajina","vulva","vulva","w0p","wh00r","wh0re","whore","xrated","xxx","b!+ch","bitch","blowjob","clit","arschloch","fuck","shit","ass","asshole","b!tch","b17ch","b1tch","bastard","bi+ch","boiolas","buceta","c0ck","cawk","chink","cipa","clits","cock","cum","cunt","dildo","dirsa","ejakulate","fcuk","fuk","fux0r","hoer","hore","jism","kawk","l3itch","l3i+ch","lesbian","masturbate","masterbat","masterbat3","motherfucker","s.o.b","mofo","nazi","nigga","nigger","nutsack","phuck","pimpis","pusse","pussy","scrotum","sh!t","shemale","shi+","sh!+","slut","smut","teets","tits","boob","boobs","b00bs","teez","testical","testicle","titt","w00e","jackoff","wank","whoar","whore","damn","dyke","fuck","shit","@$$","amcik","andskota","arse","asrammer","ayir","bi7ch","bitch","bollock","breasts","cabron","cazzo","chraa","chuj","Cock","cunt","d4m","daygo","dego","dick","dike","dupa","dziwka","ejackulate","Ekrem","Ekto","enculer","faen","fag","fancl","fanny","feces","feg","Felcher","ficken","fitt","Flikker","foreskin","Fotze","fuk","futkretzn","gay","gook","guiena","h0r","h4x0r","hell","helvete","hoer","honkey","Huevon","hui","injun","jizz","kanker","kike","lotzak","kraut","knulle","kuk","kuksuger","Kurac","kurwa","kusi","kyrpa","lesbo","mamhoon","masturba","merd","mibun","monkleigh","mouliewop","muie","mulkku","muschi","nazis","nepesaurio","nigger","rospu","paska","perse","picka","pierdol","pillu","pimmel","piss","pizda","poontsee","poop","porn","p0r","pr0n","preteen","pula","pule","puta","puto","qahbeh","queef","rautenberg","schaffer","scheiss","schampe","schmuck","screw","sh!t","sharmuta","sharmute","shipal","shiz","skribz","skurwysyn","sphencte","spic","spierdalaj","splooge","suka","b00b","testicle","titt","twat","vittu","wank","wetback","wichser","zabourah","tabernac"); $replacearray = array("****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****","****"); $newstring = str_ireplace($sweararray, $replacearray, $string); return $newstring; } } if ($photo_caption1) { $photo_caption= censor($photo_caption1); } if ($photo_details1) { $photo_details= censor($photo_details1); } if ($photo_story1) { $photo_story= censor($photo_story1); } //swear end while( $counter <= count($photos_uploaded) ) { if($photos_uploaded['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types)) { $result_final .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_details`, `photo_story`, `photo_category`, `photo_email`) VALUES('0', '".addslashes($photo_caption[$counter])."','".addslashes($photo_details[$counter])."','".addslashes($photo_story[$counter])."','".addslashes($photo_email[$counter])."','".addslashes($_POST['category'])."')" ); $new_id = mysql_insert_id(); $filetype = $photos_uploaded['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id.".".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file move_uploaded_file($photos_uploaded['tmp_name'][$counter], $images_dir . '/' . $filename); // ---------- Include Adams Universal Image Resizing Function -------- include_once("ak_php_img_lib_1.0.php"); $target_file = "$images_dir/$filename"; $resized_file = "$images_dir/$filename"; $wmax = 320; $hmax = 480; ak_img_resize($target_file, $resized_file, $wmax, $hmax, $extention); // ----------- End Adams Universal Image Resizing Function ----------- // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } // Build Thumbnail with GD 2.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = 'ImageCreateFrom' . $function_suffix; $function_to_write = 'Image' . $function_suffix; // Read the source file $source_handle = $function_to_read($images_dir . '/' . $filename); if ($source_handle) { // Let's create a blank image for the thumbnail $destination_handle = ImageCreateTrueColor($thumbnail_width, $thumbnail_height); // Now we resize it ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]); } // Let's save the thumbnail $function_to_write($destination_handle, $images_dir . '/tb_' . $filename); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />"; } } $counter++; } // Print Result echo <<<__HTML_END <html> <head> <title>Photos uploaded</title> </head> <body> $result_final </body> </html> __HTML_END; ?>
  21. Sorry. Yes, i am trying to upload text to MySQL data base. Only the first letter for the phrase is appearing Thanks!! Jason
  22. Hey guys, New to coding and I am stuck on fetching this array being uploaded by a external source. What code do I need on my php/server side to fetch this array (used print_r function): Array ( [photo_caption] => test1 [photo_details] => text2) I am using this code on my php server side to fetch it, but it only uploads the first letter of text: / Fetch the photo caption array $photo_caption1 = $_POST['photo_caption']; $photo_details1 = $_POST['photo_details']; $photo_story1 = $_POST['photo_story']; $photo_email = $_POST['photo_email']; Any help is much appreciated. Thanks!!! Jason
  23. Hey guys, I am having trouble fetching data from my iphone uploaded text. I ran the print_r for both the website upload form (which works) and the iphone function. Here is what I am getting: When I used the iphone the print_r($_POST) gives me: Response=Array ( [photo_caption] => test1 [photo_details] => text2) The upload form from the website that works gives me: Array ( [photo_caption] => Array ( [0] => test1 ) [photo_details] => Array ( [0] => test2 ) What is the best way to capture the text on my server/php side for the response: Array ( [photo_caption] => test1 [photo_details] => text2)? I can't add [] to the java script of "params.photo_caption" as it stops the app from loading correct. Here is my server/php side right now which works with the website based upload form: / Fetch the photo caption array $photo_caption1 = $_POST['photo_caption']; $photo_details1 = $_POST['photo_details']; $photo_story1 = $_POST['photo_story']; $photo_email = $_POST['photo_email']; Any help is much appreciated. I have been trying to sort this out for weeks. Jason
  24. dcro2 Thanks alot!! Worked perfect! A++++ :D :D 8) 8)
  25. Could someone please help me with this syntax error? I can't figure out what is wrong...i am a beginner. Screenshot attached. Any help is appreciated. Thanks Here is the code I am having trouble with: <?php include 'config.inc.php'; // initialization $photo_upload_fields = ''; $counter = 1; // If we want more fields, then use, preupload.php?number_of_fields=20 $number_of_fields = (isset($_GET['number_of_fields'])) ? (int)($_GET['number_of_fields']) : 5; // Firstly Lets build the Category List $result = mysql_query('SELECT category_id,category_name FROM gallery_category'); while($row = mysql_fetch_array($result)) { $photo_category_list .= <<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); // Lets build the Image Uploading fields while($counter <= $number_of_fields) { $photo_upload_fields .= <<<__HTML_END <tr><td> Photo {$counter}: <input name="photo_filename[]" type="file" /> </td></tr> <tr><td> Caption: <textarea name="photo_caption[]" cols="30" rows="1"></textarea> </td></tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <html> <head> <title>Lets upload Photos</title> </head> <body> <form enctype="multipart/form-data" action="upload.php" method="post" name="upload_form"> <table width="90%" border="0" align="center" style="width: 90%;"> <tr><td> Select Category <select name="category"> $photo_category_list </select> </td></tr> <! - Insert the image fields here --> $photo_upload_fields <tr><td> <input type="submit" name="submit" value="Add Photos" /> </td></tr> </table> </form> </body> </html> __HTML_END; ?> [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.