PHP - Client Wants Ability To Change Photos And Text, How To?
Hi there,
Apologies if this is in the wrong section, not sure what would cover it aha
I have a client who would like to be able to update her photos in the gallery weekly, and possibly update any text on the site herself (description etc). What is the best way to go about this? She used a site builder to get it up and running, but I don't have access to the host, so I don't have access to databases or know if they allow PhP.
Would an admin panel be the best way about this?
If so, would anyone mind talking me through a rough step-by-step of the process?
Similar TutorialsI am trying to set the hidden input in the javascript but it doesn't set it in the php. This is the form with the hidden input. It corresponds to a field in the database table with the name of draggables. <form method="post" accept-charset="utf-8" id="myForm2" action="/mealplans/add"> <input type="hidden" name="draggables" id="drag12"/> <button id="myId" type="submit">Submit Form</button> </form> This is where I change the value in the javascript: if(data == "draggable3"){ alert("data " + data); var x = document.getElementById("drag12").value; x = "draggable3"; alert(x); } //end if
I've also tried getElementsByName but that didn't work either. var y = document.getElementsByName("draggables").value; //only changes it on the client This is actually a cakephp site but this problem is with the PHP so I am publishing it here. Okay, I'm not quite sure how to state this, so I'll try my best. Is it possible to setup some kind of "after so long, it changes the state of something from 'fighting' to 'active'" query or function? What is happening is that people are fighting in my game, then choosing to just close their browser rather than quit the fight, to change the monster's state back to 'active', so other people can fight it. Does that make sense? Any thoughts or could someone point me in the right direction? Thanks!! I wish to create validation rules once which are used both on the client and on the server.
For instance, I will start off with the following PHP object:
stdClass Object ( [rules] => stdClass Object ( [email] => stdClass Object ( [required] => 1 [email] => 1 [remote] => stdClass Object ( [url] => check-email.php [type] => post [data] => stdClass Object ( [username] => function() {return $( '#username' ).val();} ) ) ) ) [messages] => stdClass Object ( [email] => stdClass Object ( [required] => an email is required ) ) )When the edit page is downloaded to the client, I will include this object in some format suitable to the client. The client will then use the jQuery Validation plugin (http://jqueryvalidation.org/) along with the validation object, and client side validate the page. When the form passes client side validation and is uploaded, PHP will use the same validation object to serverside validate the form (I have this part working as desired). My question is how should I pass this data to the client? Originally, I would just use PHP to write some JavaScript. exit('var myObj='.json_encode($myObj));Note that when I json_encode the object, the value of $myObj->rules->email->remote->data->username is a string with quotes around it, however, I can easily use PHP to strip these tags before sending it to the client. As Jacques1 pointed out in http://forums.phpfre...ascript-client/, I should never ever use PHP to generate JavaScript, and should use AJAX to download the JSON directly. I tried doing the later, but found that a callback function could not be included in the JSON. Please advise on the best way to accomplish this. Thank you I am working on getting members that are ready to make a payment after they have logged in and want to view their emails to make the payment first. How can I reprogram my session to stop them from entering the email section and make a payment first. This is my codes which work fine. Just need to know how to amend it to redirect them to payment. <?php //Start session session_start(); //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_ID']) || (trim($_SESSION['SESS_ID']) == '')) { header("location: access-denied.php"); exit(); } ?> Hi Have got my form working for all standard bits. Just need to add the functionality for people to upload photos. I copied and modified the form from a site and there is a section that I think is redundant it still works when I comment it out can you clarify for me: Code: [Select] // validation expected data exists /* if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } */ Below is the full code for the form: Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "asdfasdf@asdfasdf.com"; $email_subject = "adsfasdf asdfasdf Application Form"; function died($error) { // your error code can go here ?> <title>asdfas asdfasd</title> <style type="text/css"> body { background-color: #000; text-align: center; } body,td,th { color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 24px; } </style> </head> <body link="#FFFFFF" onLoad="setTimeout('history.back()',10000)"> <p><img src="../images/logo.png" width="326" height="144" alt="asdfasdf" longdesc="http://www.adsfasdf.com" /><br /> </p> <br /> <p>We are very sorry, but there were error(s) found with the form you submitted.</p> <p>Please fix the following errors:</p> <hr /> <br /> <?php echo $error; ?> <hr /> <br /> <p>Click back to fix your error(s) or you will be taken back to the form automatically in 10 seconds...</p> <h6> </h6> <h6>© asdfasdf 2012</h6> </body> </html> <?php die(); } // validation expected data exists /* if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } */ $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $age = $_POST['age']; $city = $_POST['city']; $state = $_POST['state']; $height_feet = $_POST['height_feet']; $height_inches = $_POST['height_inches']; $error_message = ""; $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'First Name: This is not a valid name.<br /><br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'Last Name: This is not a valid last name.<br /><br />'; } $age_exp = "/^(1[89]|[2-9][0-9])$/"; if(!preg_match($age_exp,$age)) { $error_message .= 'Age: You need to be at least 18+ to apply.<br /><br />'; } $phone_exp = "/^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$/"; if(!preg_match($phone_exp,$telephone)) { $error_message .= 'Phone: eg 646 555 1234 or 646-555-1234 or (646) 555 1234<br /><br />'; } $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'Email: Your address is not invalid eg yourname@emaildomain.com<br /><br />'; } if(strlen($comments) < 2) { $error_message .= 'Comments: Please leave a breif message explaining your interest and if you have any previous experience etc.<br /><br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below:\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name:"."\t".clean_string($first_name)."\n"; $email_message .= "Last Name:"."\t".clean_string($last_name)."\n"; $email_message .= "Age:"."\t".clean_string($age)."\n"; $email_message .= "Height:"."\t".clean_string($height_feet).'ft ' . clean_string($height_inches).'in'."\n"; $email_message .= "City:"."\t".clean_string($city)."\n"; $email_message .= "State:"."\t".clean_string($state)."\n"; $email_message .= "Email:"."\t".clean_string($email_from)."\n"; $email_message .= "Telephone:"."\t".clean_string($telephone)."\n"; $email_message .= "Comments:"."\t".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <title>adsfas asdfasdf</title> <style type="text/css"> body { background-color: #000; text-align: center; } body,td,th { color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 24px; } </style> </head> <body link="#FFFFFF" onLoad="setTimeout('history.back()',10000)"> <p><img src="../images/logo.png" width="326" height="144" alt="asdfasdf" longdesc="http://www.asdfasdf.com" /><br /> </p> <p>Thank your for applying to asdf adsf. We will be in touch with you very soon.</p> <p>You will be redirected back to the site in 10 seconds...</p> <h6> </h6> <h6>© adsfdasf 2012</h6> </body> </html> <?php } ?> Here is the html form: Code: [Select] <form id="form2" action="./php/joinus.php" method="post" enctype="multipart/form-data"> <fieldset> <div class="wrapper"> <div class="fleft col"> <label class="first_name"> <span class="text-form">Name:</span> <input name="first_name" type="text" value=""> </label> <label class="age"> <span class="text-form">Age:</span> <input name="age" type="tel" value=""> </label> <label class="city"> <span class="text-form">City:</span> <input name="city" type="text" value=""> </label> <label class="telephone"> <span class="text-form">Phone:</span> <input name="telephone" type="tel" value=""> </label> </div> <div class="fleft col2"> <label class="last_name"> <span class="text-form">Last Name:</span> <input name="last_name" type="text" value=""> </label> <span id="validate_height"> <label><span class="text-form">Height:</span> <select style="width:109px;" name="height_feet"> <option value="" selected="selected">Feet</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> <select style="width:109px;" name="height_inches"> <option value="" selected="selected">Inches</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> </select> </label> </span> <label class="state"> <span class="text-form">State:</span> <select name="state"> <option value="" selected="selected">Select a State</option> <option value="Alabama">Alabama</option> <option value="Alaska">Alaska</option> <option value="Arizona">Arizona</option> <option value="Arkansas">Arkansas</option> <option value="California">California</option> <option value="Colorado">Colorado</option> <option value="Connecticut">Connecticut</option> <option value="Delaware">Delaware</option> <option value="District Of Columbia">District Of Columbia</option> <option value="Florida">Florida</option> <option value="Georgia">Georgia</option> <option value="Hawaii">Hawaii</option> <option value="Idaho">Idaho</option> <option value="Illinois">Illinois</option> <option value="Indiana">Indiana</option> <option value="Iowa">Iowa</option> <option value="Kansas">Kansas</option> <option value="Kentucky">Kentucky</option> <option value="Louisiana">Louisiana</option> <option value="Maine">Maine</option> <option value="Maryland">Maryland</option> <option value="Massachusetts">Massachusetts</option> <option value="Michigan">Michigan</option> <option value="Minnesota">Minnesota</option> <option value="Mississippi">Mississippi</option> <option value="Missouri">Missouri</option> <option value="Montana">Montana</option> <option value="Nebraska">Nebraska</option> <option value="Nevada">Nevada</option> <option value="New Hampshire">New Hampshire</option> <option value="New Jersey">New Jersey</option> <option value="New Mexico">New Mexico</option> <option value="New York">New York</option> <option value="North Carolina">North Carolina</option> <option value="North Dakota">North Dakota</option> <option value="Ohio">Ohio</option> <option value="Oklahoma">Oklahoma</option> <option value="Oregon">Oregon</option> <option value="Pennsylvania">Pennsylvania</option> <option value="Rhode Island">Rhode Island</option> <option value="South Carolina">South Carolina</option> <option value="South Dakota">South Dakota</option> <option value="Tennessee">Tennessee</option> <option value="Texas">Texas</option> <option value="Utah">Utah</option> <option value="Vermont">Vermont</option> <option value="Virginia">Virginia</option> <option value="Washington">Washington</option> <option value="West Virginia">West Virginia</option> <option value="Wisconsin">Wisconsin</option> <option value="Wyoming">Wyoming</option> </select> </label> <label class="email"> <span class="text-form">E-mail:</span> <input name="email" type="text" value=""> </label> </div> </div> <label class="message"> <span class="text-form">Comments:</span> <textarea name="comments"></textarea> </label> <label> <span class="text-form2">Attach a photo:</span> <input id="photo" name="file[]" type="file" class="fl" > </label> <label> <span class="text-form2">Attach a photo:</span> <input id="photo" name="file[]" type="file" class="fl" > </label> <label> <span class="text-form2">Attach a photo:</span> <input id="photo" name="file[]" type="file" class="fl" > </label> <div class="but"><a class="link1 link-color2" data-type="submit" onClick="document.getElementById('form2').submit()">Submit</a></div> </fieldset> </form> From what I've been reading you need to tell the php to put it to a temporary file from the submit.. then move it to the file name and then somehow include that file name in the php email back. So maybe a url and its private or htaccess? or does it get included as attachment in the mail? Im not sure if i should be using 'id' or 'name' in the html form etc and how to tie it together. Any help or guides much appreciated. Thanks Wolfsta change link text Code: [Select] <?php require 'connect.php'; ?> <html> <head><title>Admin</title> <link rel="stylesheet" type="text/css" href="tab_style.css"> <script type="text/javascript"> function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function approve(e) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById("appr <?php echo $fet['s_id']; ?>").innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", "approve.php?stu="+e, true); req.send(null); } } function block(b) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('blok').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", "block.php?blo="+b, true); req.send(null); } } </script> </head> <body> <?php $admin_err=''; $pass_err=''; if (isset ($_REQUEST['submit'])) { require 'connect.php'; $admin = $_REQUEST['admin']; $pass = $_REQUEST['password']; $err=0; if($admin=="") { $admin_err="enter username"; $err=1; } if($pass=="") { $pass_err="enter password"; $err=1; } if ($err == 0) { $check = mysql_query("SELECT admin FROM admin_login WHERE admin='".$admin."' and password='".$pass."' "); $exi = mysql_num_rows ($check); if($exi == 0) $err_msg = "Username/password combination incorrect."; else { $sel = mysql_query("SELECT * FROM stud"); echo "<h4 class='table-caption'>Students</h4>"; while ($fet = mysql_fetch_array($sel)) { ?> <div class="base-layer"> <div class="table-row"> <div class="c_one"><p class="text"> <? echo $fet['name']; ?></p></div> <div class="c_two"><p class="text"> <? echo $fet['email']; ?></p></div> <div class="c_three"><p class="text"> <? echo $fet['school']; ?></p></div> <div class="c_four"><p class="text"> <? echo $fet['subject']; ?></p></div> <div class="c_five"><p class="text"> <? echo $fet['class']; ?></p></div> <div class="c_six"><p class="text"> <? echo $fet['teacher']; ?></p></div> <div class="c_seven" id="appr <?php echo $fet['s_id']; ?>"><p class="text"> <?php if ($fet['approve'] == 0) ?> <a href="#" onClick="return approve(<?php echo $fet['s_id']; ?>);" style="text-decoration:none"> Approve</a> </p> </div> <div class="c_eight" id="block"><p class="text"> <?php if($fet['approve'] == 1) ?> <a href="#" onClick="block(<?php echo $fet['s_id']; ?>);" style="text-decoration:none"> Block </a> </p> </div> <div class="space-line"> </div> </div> </div> <?php } die(mysql_error()); } } } ?> <form id="formid" method="post" name="myform" action=""> <p> <label for="username">Admin:</label> <input name="admin" type="text" size="20" value="<?php if(isset($admin)) echo $admin; ?>" /> <?php echo $admin_err; ?> </p> <p> <label for="pass">Password:</label> <input name="password" type="password" value="<?php if(isset($pass)) echo $pass;?>" /> <?php echo $pass_err; ?> </p> <p> <input name="submit" type="submit" value="Log in" > </p> <?php if(isset($err_msg)) echo $err_msg; ?> </form> </body> </html> approve.php Code: [Select] <?php require_once 'connect.php'; $id = $_REQUEST['stu']; $upd = mysql_query ("UPDATE stud SET approve = '1' WHERE s_id = ".$id." "); if (!$upd) die(mysql_error()); //header("Location:administrator.php"); echo "Approved"; //echo "<h3>Student Approved</h3>"; ?> This is what I have now and need to change "" Thanks "" to some kind of picture ?> <html><style type="text/css"> <!-- body { background-color: #fff; } body,td,th { color: #000; } --> </style> <body> Thanks </body> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=342245.0 Hi,
I have the following submit button and would like to change it into a link with a class.
<input type="image" alt="Click here to Continue" name="I2" src="altimages/buttons/continue.gif" id="submit">How would I do this using jQuery? Thanks! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=357414.0 How should I go about keeping track of photos that a user has rated, since I only want the user to rate the photo once? Can I store arrays in a mysql database? thanks, George I have some thousands of photos about nature I ll let visitors/members to see them one by one, but I dont want to show them the same photo again after they visit 1 week later How can I do this ? What I think as a solution is; For members; I can store the ids (like "everest01") of the photos that member has visited , and show user the most visited photos that he/she has not see for next visit. But what I m wondering is, how will I take the photos from DB ? select * from photos WHERE id not in ( $thousandsofvisitedphotoids ) ?? I m stuck here ? For visitors ( not members ) ; I can set a cookie that keeps the ids of visited photos.. when visitor visits the website again, I take the cookie and sent to $thousandsofvisitedphotoids and make a query again ? I m stuck here, How you guys do this ? what's the logic of this ? Hi! I am creating a small project somewhat like a photo gallery as my first practice page. I just would like to know how can I alter photos or file in php. Or should I just do a delete and then upload a new one? Thanks in advance... How to add the ability to login with username or email for login?
<?php ob_start(); include('../header.php'); include_once("../db_connect.php"); session_start(); if(isset($_SESSION['user_id'])!="") { header("Location: ../dashboard"); } if (isset($_POST['login'])) { $email = mysqli_real_escape_string($conn, $_POST['email']); $password = mysqli_real_escape_string($conn, $_POST['password']); $result = mysqli_query($conn, "SELECT * FROM users WHERE email = '" . $email. "' and pass = '" . md5($password). "'"); if ($row = mysqli_fetch_array($result)) { $_SESSION['user_id'] = $row['uid']; $_SESSION['user_name'] = $row['user']; $_SESSION['user_email'] = $row['email']; header("Location: ../dashboard"); } else { $error_message = "Incorrect Email or Password!!!"; } } ?>
I have a page for image uploads and I just realized it will only work if a user already has on picture uploaded. If they don't it won't work. The ones that do fail some photos anyway which is probably that they don't pass the image check but when I put echoes in there to trace what happens any user with an empty gallery can't upload a photo because the page says there is no file in the $_FILES['image']['name'] variable. Here are the initial conditions and the form (leaving out the image processing etc since that works): Code: [Select] if (!isset($_SESSION['user'])) die("<br /><br /> You need to log in to view this page"); $user = sanitizeString($_SESSION['user']); $view = sanitizeString($_GET['view']); $dir = './grafik/users/'.$user.'/big/'; $files = scandir($dir); $len = count($files); $nr= $len-1; $maxPhotos = 8; if ($view == $user) { echo "view is user"; if(!file_exists("grafik/users/$user")) { mkdir("grafik/users/$user"); mkdir("grafik/users/$user/big/");} } if (!isset($_FILES['image']['name'])) echo "There is no file <br />$dir - $user - $nr"; if (isset($_FILES['image']['name'])) { echo "<br />...is a file <br />$dir - $user - $nr"; $photoName="$dir$user$nr.jpg"; move_uploaded_file($_FILES['image']['tmp_name'], $photoName); $typeok = TRUE; .... <form method='post' action='gallery.php?view=$user' enctype='multipart/form-data'> Upload another photo: <br /> Max $maxPhotos allowed, max filesize 2Mb <br /> <input type='file' name='image' size='10' /><br /> <input type='submit' value='Upload' /> </form> I can't see why it wouldn't let me but I have a feeling someone here knows why. I have users becoming members and allowed them to upload their own photos. But when they try to upload 5MB photos, it takes time to upload the photo, and sometimes server gives a timeout error. I have searched and found javascripts that uploads to the server but I have noticed that it has security problems. So how do you let users to upload photos ? Hello. My website has a photo gallery of thumbnails that is created by reading all photo files in a specified directory. Here is my function that builds the array which is ultimately displayed in the gallery...
<?php function getPhotoFilesArray($photoPath){ /** * Takes path to photo-directory, and returns an array containing photo-filenames. */ // Initialize Array. $photoFiles = array(); // Check for Photo-Directory. if (is_dir($photoPath)){ // Photo-Directory Found. // Open Directory-Handle. $handle = opendir($photoPath); // Open Photo-Directory. if($handle){ // Initialize Key. $i = 1001; // Iterate through Photo-Directory items. while(($file = readdir($handle)) !== FALSE){ // Return next Filename in Directory. // Define fullpath to file/folder. $fullPath = $photoPath . $file; // Populate Array. if(!is_dir($fullPath) && preg_match("#^[^\.].*$#", $file)){ // Not Directory. // Not Hidden File. // Add to array. $photoFiles[$i] = $file; $i++; }//End of POPULATE ARRAY. }//End of ITERATE THROUGH PHOTO-DIRECTORY ITEMS closedir($handle); }//End of OPEN PHOTO-DIRECTORY }else{ // Photo-Directory Not Found. // Redirect to Page-Not-Found. header("Location: " . BASE_URL . "/utilities/page-not-found"); // End script. exit(); }//End of CHECK FOR PHOTO-DIRECTORY return $photoFiles; }//End of getPhotoFilesArray ?>
Everything works fine locally in DEV, but when I uploaded my website (and photos) onto a webserver, the photos are appearing in a backwards order in PROD. This is annoying, because I want the photos displayed chronologically from oldest (first) to newest (last). I'm not sure where the problem is happening, because each photo was taken with my camera and by nature of the camera, photo names are incremented by one, so IMG_001.jpg would have been taken FIRST, followed by IMG_002.jpg, IMG_003.jpg, and so on. How can I fix things so the photos are displayed in the order they were physically taken AND match how things display locally in DEV? Thanks!
Hi friends, I have two mysql db tables, photos and album, I would like to list photos by album how do i do that ? CREATE TABLE `album` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `album_name` varchar(95) NOT NULL, `album_desc` text NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `photos` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `album_id` int(11) NOT NULL, `thumb_name` varchar(255) NOT NULL, `photo_name` varchar(250) NOT NULL, PRIMARY KEY (`id`) ) This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=354562.0 I was thinking of a board where you can bookmark the photos from Facebook.
It may require an App and a "Facebook Login" for the website, so one can bookmark photos from Facebook. The website would have additional features for the photos.
I thought of an "Add to ..." function.
Is this possible with the Facebook API?
Edited by glassfish, 07 October 2014 - 02:31 PM. |