Jump to content

Search the Community

Showing results for tags 'edit'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 9 results

  1. Hi all, I have the following code to add a new line in a text file: if(!empty($name)){ $fp = fopen($croom."_test.txt", 'a'); fwrite($fp, '<div id="'.$id.'"><b>'.$name.'</b>: '.$msg.'<br/></div>'.PHP_EOL); fclose($fp); } Everytime this is executed, the text file will grow like this: <div id="234"><b>Jake</b>: blabla<br/></div> <div id="345"><b>Sam</b>: sfsfe<br/></div> <div id="234"><b>Jake</b>: yyujyuj<br/></div> <div id="098"><b>Bob</b>: bnhngn<br/></div> In time this text file will grow huge. I want to prevent this by overwriting the line containing a certain word/ id (lets say: 234) In the example above you see that Jake is in there twice, this should not be allowed. The second line from Jake should overwrite the first line from him, so each id has just 1 line of text in the text file. How to do this? How to edit my code above to achieve this? Hope anyone can help. Many thanks A coding newbie
  2. Sir/ma'am, With the script I'm using to run my website, I've been trying to add an additional feature for the users to add/edit. I'll try to provide as much info as I can, hopefully it'll help. Here is the code I'm using to display the user's unique info from the db. <a class="wallet-edit"><?php echo $_SESSION['simple_auth']['INFO']?></a> That displays the user's info from the column 'INFO' perfectly. It's also a js popup to a menu to where I'm hoping to add a single textbox to edit the INFO. The script uses a similar function to edit the password with a popup. I've tried modifying the code to edit the INFO column but it doesn't work. Here is the default code it has to edit the password. I'm not sure if it can be changed to edit another column or needs a new piece of code for that. // user edit $('body').on('click', '.username-edit', function() { $('#modal').html(' '); var output = '<div class="modal-content"><h5><?php echo lang::get("Change password")?></h5><hr />'; output += '<h5><?php echo lang::get("New password:")?></h5><input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />'; output += '<h5><?php echo lang::get("Confirm password:")?></h5><input type="password" name="password2" id="password2" value="" class="text ui-widget-content ui-corner-all" />'; output += '</div>'; output += '<div class="modal-buttons right">'; output += '<button id="confirm-button" type="button" class="nice radius button"><?php echo lang::get("Change")?></button>'; output += '</div>'; output += '<a class="close-reveal-modal"></a>'; $('#modal').append(output); $('#second_modal').hide(); $('#modal').reveal(); $('#confirm-button').click(function(){ $('#password').css('border-color', '#CCCCCC'); $('#password2').css('border-color', '#CCCCCC'); var password = $('#password').val(); var password2 = $('#password2').val(); if(typeof(password) === 'undefined' || password == ''){ $('#password').css('border-color', 'red'); return false; } if(password != password2){ $('#password2').css('border-color', 'red'); return false; } password_data = encodeURIComponent(password); $.post("<?php echo gatorconf::get('base_url')?>", { changepassword: password_data} ).done(function(data) { // flush window.location.href = '<?php echo gatorconf::get('base_url')?>'; }); }); }); If the code above can be edited to work with what I'm trying to do, it of course only needs one textbox and doesn't have to be confirmed by a second input. Please help! Thanks!
  3. The first file adds images correctly but if you want to edit the product, this form ignores the new image. It's not sending it to the file even if there is no previous image, so it's not an overwrite issue (I have other files overwriting images in the same site). It shows the temp name of the image, echoes the success message & updates the db but simply will not move that image. <?php session_start(); include('functions.php'); if (verifySession(getSession(session_id())) != true) { // only returns true for role of Administrator header('Location: noaccess.php'); } dbConnect(); $success=""; $problem=""; $title=""; $author_name=""; $price=""; $pub_name=""; $description=""; $description_b=""; $fileField=""; $newname=""; $product_id=""; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['getListing'])) { $title= mysql_real_escape_string($_POST['title']); $sql=mysql_query("Select * FROM product WHERE title='$title' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $product_id=$row["product_id"]; $title=$row["title"]; $author_name=$row["author_name"]; $price=$row["price"]; $pub_name=$row["pub_name"]; $description=$row["description"]; $description_b=$row["description_b"]; } } if (isset($_POST['title']) && ($_POST['author_name']) && ($_POST['price']) &&($_POST['pub_name']) && ($_POST['description'])&& ($_POST['description_b'])){ { if (isset($_POST['submit']) && (!$problem)) { $product_id= mysql_real_escape_string($_POST['product_id']); $title= mysql_real_escape_string($_POST['title']); $author_name = mysql_real_escape_string($_POST['author_name']); $price= mysql_real_escape_string($_POST['price']); $pub_name= mysql_real_escape_string($_POST['pub_name']); $description= mysql_real_escape_string($_POST['description']); $description_b= mysql_real_escape_string($_POST['description_b']); $fileField=$_FILES['fileField']; //$fileField=(isset($_FILES['fileField'])); mysql_query("UPDATE product SET title='$title', author_name='$author_name', price='$price',pub_name='$pub_name', description='$description',description_b='$description_b' WHERE product_id= '$product_id'") or die (mysql_error()); $success='Updated ' .$title. '.'; if ($_FILES[$fileField]['tmp_name'] != "") { //Place image in the folder $product_id=mysql_insert_id();//how it tags the image in addBook, makes no difference with or w/o it here $newname = 'product' . $product_id. '.jpg'; move_uploaded_file($_FILES[$fileField]['tmp_name'], "product_images/$newname"); } } } } } //} ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Edit a Listing</title> <link rel="stylesheet" type="text/css" href=".././project.css"> <link rel="icon" type="image/png" href="https://<snip>/iShop/project_images/icon.png" > <script type="text/javascript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body onload="MM_preloadImages('../project_images/inventory_down.png')"> <?php include('header.php');?> <?php include('.././footer.php');?> <div id="pageContent"> <p align = "center"><a href="index.php"><img src="../project_images/admin.png" width="609" height="71" alt="Admin Panel" /></a></p> <br /> <div id="addBook"> <form action="<?php htmlentities($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data" name="editBook" class="addBook_bg" method="post"> <a href="seeBooks.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Inventory','','../project_images/inventory_down.png',1)"><img src="../project_images/inventory.png" alt="Inventory" name="Inventory" width="336" height="86" border="0" id="Inventory" /></a> <h2> Edit a Listing</h2><br/><br/> <?php //echo $book; ?> <table width="90%" border="0" cellspacing="0" cellpadding="6"> <tr> <td width="20%" align="right">Title</td> <td width="80%"> <input name="title" type="text" id="title" size="30" maxlength="100" class="form_input" value="<?php echo $title; ?>" /><input type="submit" name="getListing" id="getListing" value="Get Listing" /><br/><?php if(isset($_POST['submit'])) { $title=preg_replace('#[^a-z0-9?!-: (),]#i','',$_POST['title']); if($title =="" ){ echo '<span class="warning"></span>Please enter a title.</span>'; $problem = TRUE;}} ?> </td> </tr> <tr> <td align="right">Author</td> <td> <input name="author_name" type="text" id="author_name" size="30" maxlength="80" class="form_input" value="<?php echo $author_name; ?>"/><?php if(isset($_POST['submit'])) { $author_name=preg_replace('#[^a-z ]#i','',$_POST['author_name']); if($author_name =="" ){ echo '<span class="warning"></span>Please enter the author.</span>'; $problem = TRUE;}} ?> </td> </tr> <tr> <td align="right">Price</td> <td><input type="text" name="price" id="price" size="30" maxlength="7" class="form_input" value="<?php echo $price; ?>" /><?php if(isset($_POST['submit'])) { $price=preg_replace('#[^0-9.]#i','',$_POST['price']); if($price =="" ){ echo '<span class="warning"></span>Please enter the price.</span>'; $problem = TRUE;}} ?> </td> </tr> <tr> <td align="right">Publisher</td> <td><input type="text" name="pub_name" id="pub_name" size="30" maxlength="80" class="form_input" value="<?php echo $pub_name; ?>" /><?php if(isset($_POST['submit'])) { $pub_name=preg_replace('#[^a-z0-9?!-: (),]#i','',$_POST['pub_name']); if($pub_name =="" ){ echo '<span class="warning"></span>Please enter the publisher.</span>'; $problem = TRUE;}} ?> </td> </tr> <tr> <td align="right">Description</td> <td> <textarea name="description" type="text" id="description" cols="40" rows="6" maxlength="250" class="text_box" /><?php echo $description; ?></textarea><br/><?php if(isset($_POST['submit'])) { $description=preg_replace('#[^a-z0-9?!-: (),]#i','',$_POST['description']); if($description =="" ){ echo '<span class="warning"></span>Please enter the description.</span>'; $problem = TRUE;}} ?> </td> </tr> <tr> <td align="right">Detail</td> <td> <textarea name="description_b" type="text" id="description_b" cols="40" rows="6" maxlength="250" class="text_box" /><?php echo $description_b; ?></textarea><br/><?php if(isset($_POST['submit'])) { $description_b=preg_replace('#[^a-z0-9?!-: (),]#i','',$_POST['description_b']); if($description_b =="" ){ echo '<span class="warning"></span>Please enter the detail.</span>'; $problem = TRUE;}} ?> </td> </tr> <tr> <td align="right">Picture</td> <td> <input type="file" name="fileField" id="fileField" /> </td> </tr> <tr> <td> </td> <td> <input name="product_id" type="hidden" value="<?php echo $product_id; ?>" /> <input type="submit" name="submit" id="submit" /> <input type="reset" onclick="location.reload('editBook.php');return false;"/> <?php echo $success ?> </td> </tr> </table> <br/><br/> </form> <br /><br /> </div> </div> </body> </html>
  4. Hi I'm working in a project and I just finished the pagination system (in every page 2 results) but my problem is that I want to add some options beside every result.For example I have to resut which are (john,katy)I want them to be like this : John (Edit) (Delete) Katy (Edit) (Delete) This is my code : <?php include("wasata/inc/config.php"); mysql_query('SET NAMES "UTF-8"'); if(!isset($_GET['page'])){ $page = 1; }else{ $page = (int) $_GET['page']; $records_at_page = 2; $q = mysql_query('SELECT * FROM serv'); $records_count = @mysql_num_rows($q); @mysql_free_result($q); $page_count = (int) ceil($records_count / $records_at_page); if(($page > $page_count) || ($page <= 0)){ mysql_close($con); die('No More Pages'); } $start = ($page - 1) * $records_at_page; $end = $records_at_page; if($records_at_page != 0){ $q = mysql_query("SELECT * FROM serv ORDER BY id ASC LIMIT $start,$end"); while($o = mysql_fetch_object($q)){ echo $o->title .'<br />'; } } echo '<br />'; for($i = 1; $i<= $page_count; $i++){ if($page == $i){ echo $page; }else{ echo '<a href="m.php?page=' .$i . '">' .$i . '</a>'; if($i != $page_count){ echo ' - '; } } } } mysql_close($con); ?> So can any one Help please.
  5. Hi, I'd like to make a site that, basically, allows members to create their own page once they receive something like a code/password from me. The page is going to have some basic information but some of the info needs to be editable through the person. Some examples are http://www.laidofftopaidoff.com/go/752705.php (under the Step 2 button, there should be two fields and a "GENERATE" button - if you don't see these, scroll til about the middle/end of the video and it should appear) and http://instantpaydaynetwork.com/jeffbuchanan . (sorry; not sure how I can format these links without making them clickable) A lot of these online marketers have these types of websites so I feel like there must be some basic program/software/code that they're all using, as each site is pretty similar. I think that if someone just leads me in the right direction, I should be able to figure the rest out. Thanks for your help!
  6. Hope this is the right topic for my problem and maybe someone can help me with this! My blog is in wordpress and when you look at the default category page it looks empty, just plain post list so i figured it would be nice to have last few category posts before the content. With the theme which I'm using silverOrchid i already have front page slider which i like so i would like to copy that slider in the category.php which i created earlier and change it to show and change latest posts per category which users are reading. Here is slider code from index.php //include slider if ( $gazpo_settings['gazpo_show_slider'] == 1 ) { get_template_part('includes/slider'); } So my question is how to change this code (if possible) to show latest posts from category which users are reading? I tried a few different forum threads but non of them seams understandable enough for me so i would appreciate help .... thanx
  7. I have a problem when i Click the Edit button int he form, the database doesn't update, In the beginning i thought i had a problem with the query, but I did a check as a query and everything was fine. Can someone suggest something please. //this is the file - album.func.php function edit_album($album_id, $album_name, $album_description) { $album_id = ((int)$album_id); $album_name = mysql_real_escape_string($album_name); $album_description = mysql_real_escape_string($album_description); mysql_query("UPDATE `albums` SET `name`='$album_name', `description`='$album_description' WHERE `album_id`='$album_id' AND `user_id`=".$_SESSION["user_id"]); } //this is the file - edit_album.php if (!empty($errors)) { foreach ($errors as $error) echo $error; }else { edit_album($album_id, $album_name, $album_description); header('Location: index.php'); exit(); }} ?> <?php $album_id = $_GET["album_id"]; $album_data = album_data($album_id, 'name', 'description'); ?> //this is the form <form action="?album_id=<?php echo $album_id; ?>" method="post"> <p>Name:</br><input type="text" name="album_name" maxlength="55" value="<?php echo $album_data["name"]; ?>"/></p> <p>Description:</br><textarea name="album_description" rows="6" cols="35" maxlength="500"><?php echo $album_data["description"]; ?>
  8. If i hit Edit button i got these error before i click Submit <? if ($_GET['do'] == 'test2') { $id = ($_POST['id']); $username = cleanuserinput($_POST['username']); $password = cleanuserinput($_POST['password']); $rpassword = cleanuserinput($_POST['rpassword']); $pass = md5($_POST['password']); if(isset($_POST['delete'])){ mysql_query("delete from admin where id='".$id."'"); print '<center><font color=black>Admin has been deleted!</font><br>'; } if(isset($_POST['edit'])){ //Make sure username isn't blank if (!$username){ $error .= '<font color=red>Sorry, the username was empty.</font><br>'; } //Make sure password isn't blank if (!$password){ $error .= '<font color=red>Sorry, your password was empty.</font><br>'; } //Make sure both passwords match if ($password != $rpassword) { $error .= '<font color=red>Passwords Doesn\'t Match!</font><br>'; } //Check username length if (!ctype_alnum($username) || strlen($username) < 4 || strlen($username) > 15) { $error .= '<font color=red>Username must be between 4-15 characters!</font><br>'; } //Check password length if (!ctype_alnum($password) || strlen($password) < 4 || strlen($password) > 15) { $error .= '<font color=red>Password must be between 4-15 characters.</font><br>'; } if (!$error){ $sql_update = "UPDATE admin set username = '$username', password= '$pass' where id='".$id."'"; $result = mysql_query ($sql_update) or die(mysql_error()); print "<center><font color=black>User ". $_POST['username'] ." Has been edited.</font><br>"; } $get_admin = mysql_query("select * from admin where id='".$id."'"); $admin = mysql_fetch_array($get_admin); echo $error . "<form action='?do=test2' method='post'> <table> <tr><th colspan=20>Edit Admin</th></tr> <tr><td><b>Username<font color=red>*</font></b></td><td><div><small>[ 4-15 characters ]</small></div><input name='username' type='text' maxlength='50' size='25' tabindex='1' value='".$admin['username']."'></td></tr> <tr><td><b>Password<font color=red>*</font></b></td><td><div><small>[ 4-15 characters ]</small></div><input name='password' type='text' maxlength='50' size='25' tabindex='2' value=''></td></tr> <tr><td><b>Password 2<font color=red>*</font></b></td><td><input name='rpassword' type='text' maxlength='50' size='25' tabindex='3' value=''></td></tr> </table> <input type=hidden name=id value='".$admin['id']."'> <div align='center'><br><input type='submit' name='submit' tabindex='4' value='Submit'></div> </form>"; } else { print" <table width=90%> <tr><th colspan=20>Current Admin</th></tr> <td>Admin Name</td> <td>Added Date</td> <td align=center>Action</td>"; $get_admin = mysql_query("select * from admin "); while ($row = mysql_fetch_array($get_admin)){ print " <tr> <td>". $row['username'] ."</td> <td>". $row['date'] ."</td> <td align=center> <form method=POST> <input name=id type=hidden value='".$row['id']."'> <input type=submit name=edit value='Edit'> <input type=submit name=delete value='Delete'> </td> </form> </tr>"; } print "</table>"; } } else { admin_wrong_file(); } ?>
  9. Hello all, I'm fairly new to php, and can't figure this thing out: Mysql design: Table_users: ID,USERNAME 1,Name1 2,Name2 Table_comments: ID,USERNAME_ID,COMMENT 1,1,"Comment 1" 2,1,"Comment 2" I use a for loop to fill a form with <input type=”text”> So i have the following output: Name: Name1 Comments:(input type=text) Comment 1|Delete? Comment 2|Delete? |Add I want to be able to edit the existing comments, or add a new comment. How can I?: -list all the comments, and display one extra <input> form for a new comment -make sure that if i edit both “comment 1” and “comment 2” all gets executed as a mysql command -perhaps make it possible to edit “comment 1” and the new blank “comment 3” at the same time If anyone can help me out, it would be great Thanks in advance. Luuk
×
×
  • 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.