techiefreak05 Posted July 30, 2006 Share Posted July 30, 2006 Hello, I'm creating a website that allows users to have a profile .... I have a profile editor...but they have to know HTML for it to be nice. [color=red]how can i add a pre defined layout and add little snippets they can edit without the knowledge of HTML???[/color] (yeah. like MySpace..) Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/ Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 You can try bbcodes, just like every forums does. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65779 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 How can I do that ... sorry for the dumb qauestion .. if heard of that before I jsut don't know what it is! Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65780 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 You can try to search around for bbcode, btw.. This is the function I'm using[code]function bbcode($text){$pattern[] = '//';$replace[] = '';$pattern[] = '/\n/';$replace[] = '<br>';$pattern[] = '/\[b\](.*?)\[\/b\]/';$replace[] = '<span style="font-weight:bold">$1</span>';$pattern[] = '/\[i\](.*?)\[\/i\]/';$replace[] = '<span style="font-style:italic">$1</span>';$pattern[] = '/\[u\](.*?)\[\/u\]/';$replace[] = '<span style="text-decoration:underline">$1</span>';$pattern[] = '/\[color=(.*?)\](.*?)\[\/color\]/';$replace[] = '<span style="color: $1">$2</span>';$pattern[] = '/\[url=(.*?)\](.*?)\[\/url\]/';$replace[] = '<a href="$1">$2</a>';$pattern[] = '/\[url\](.*?)\[\/url\]/';$replace[] = '<a href="$1">$1</a>';$pattern[] = '/\[img\](.*?)\[\/img\]/';$replace[] = '<img src="$1">';$pattern[] = '/\[b\](.*?)\[\/b\]/';$replace[] = '<b>$1</b>';$text = preg_replace($pattern, $replace, $text);return $text;}[/code]Useage:[code]<?phpecho bbcode("[b]Bold[/b]");?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65785 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 How would I incorporate that into my site ... That makes no sense.... Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65791 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Wait, now that I look at it... I don't think thats what im looking for.. I'm looking for seomthing that allows users to edit a certain area of a webpage. lets say they enter their name into a textbox in editProfile.hph and they click the save button, it displays their name in an area .. I guess what im saying is how do i get a profile editor like myspace. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65794 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 Sorry, I never used before myspace so I'm not really sure how it function.Hmm.. Are you trying to edit their profile ? Then you can create a form and has value="" on it. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65797 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Yeah i want them to be able to edit their profile. I want the editprofile page to have multiple textboxes and each textbox edits a certain piece of code on a page... Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65801 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 Are all your members information stored in database ? Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65805 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Yes. a MySQL DB, yeah, it has their Username, Password(md5 encrypted) and e-mail address. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65807 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 Then before those textboxes, you put something like $_GET['id'];Then do a sql query, example:[code]$id = $_GET['id'];$query = "SELECT * FROM members WHERE id='$id'";$result = mysql_query($query) or die("There's some problem with the query");$row = mysql_fetch_assoc($result);[/code]Next, at the textboes, remember to put value="$row['username]''" etcs..Then the person go to http://domain/editprofile.php?id=[b]1[/b]It will display the textbox with all his informations. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65812 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Ok, well um I guess that's kinda over my head. I'm sorry, I'm new to PHP... :( and I don't get how that would do what i want it to.... Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65814 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 Have you done scripting the html part (those text boxes) ? Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65815 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 No, but It'll take me 5 seconds to make the boxes..lol Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65816 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 Ok, so you make it now.All those boxes that you want to let your members to edit them and post the html scripts here.Btw.. You have to indicate which boxes is for which.So let's say you allow them to change their email address put[b]Email:[/b] infront so I know :P Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65818 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Ok, ill get back to you in a bit. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65819 Share on other sites More sharing options...
hostfreak Posted July 30, 2006 Share Posted July 30, 2006 You also need to update the mysql database with the new information they enter. Heres an example of what you would do:[code]<?php$connection = mysql_connect("$server","$user","$password");$id = $_GET['id'];mysql_select_db ($database);$example1 = $_POST['example1'];$example2 = $_POST['example2'];$id = $_POST['id'];$query = "UPDATE table SET example1 = '$example1', example2 = '$example2', id = '$id' WHERE id = $id";$result = mysql_query($query); echo "Your profile has been updated!";} else {?><table><?php$sql = mysql_query("SELECT * FROM table WHERE id='$id'"); while ($row = mysql_fetch_array($sql)) {$id = $row["id"];$example1 = $row["example1"];$example2 = $row["example2"];}?><form name='updatefile' method='POST' action="<?php echo $_SERVER['PHP_SELF']"; ?>"><tr><td>Example1:</td><td> <input type='text' name='example1' value='<?php echo "$example1"; ?>'></td></tr><tr><td>Example2:</td><td> <input type='text' name='example2' value='<?php echo "$example2"; ?>'></td></tr><input type='hidden' name='id' value='<?php echo "$id"; ?>'></form></table><?php}?>[/code]Change the "table" to your mysql table, then change the examples to the rows your using etc. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65823 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 [code]<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"><table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td>Name</td><td><input type="text" name="name" maxlength="30"></td></tr><tr><td>Location</td><td><input type="text" name="location" maxlength="30"></td></tr><tr><td>Age</td><td><input type="text" name="age" maxlength="30"></td></tr></table></form>[/code]thats a rough idea of what ill have, and i want the contents of those boxes that they have to be posted in a certain area on their profile when they click a button**thats not the whole page.. its just the editing prt** Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65825 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Another thing:What they enter into any of the boxes. will NOT be stored on a db, it has no reason to be .... its just writing to their profile.. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65827 Share on other sites More sharing options...
hostfreak Posted July 30, 2006 Share Posted July 30, 2006 Alright, here is how you would call the information for them to edit:[code]<table><?php//your database information, or include the file that has it$connection = mysql_connect("$server","$user","$password");$id = $_GET['id'];$sql = mysql_query("SELECT * FROM table WHERE id='$id'"); while ($row = mysql_fetch_array($sql)) {$id = $row["id"];$name = $row["name"];$location = $row["location"];$age = $row["age"]}?><form name='updatefile' method='POST' action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']"; ?>"><tr><td>Name:</td><td> <input type='text' name='name' value='<?php echo "$name"; ?>'></td></tr><tr><td>Location:</td><td> <input type='text' name='location' value='<?php echo "$location"; ?>'></td></tr><tr><td>Age:</td><td> <input type='text' name='age' value='<?php echo "$age"; ?>'></td></tr><input type='hidden' name='id' value='<?php echo "$id"; ?>'></form></table>[/code]From there add what you need, to update it how you want. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65831 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 This is roughly how it look like[code]<?php// MySQL Connection$host = "localhost";$username = "root";$password = "";$db = "database";mysql_connect($host,$username,$password) or die(mysql_error());mysql_select_db($db) or die(mysql_error());$id = $_GET['id'];if (isset($id)){ $query = "SELECT * FROM members WHERE id='$id'"; $result = mysql_query($query) or die("There's some problem with the query."); $row = mysql_fetch_assoc($result); if (!isset($_POST['submit'])) {?><form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"><table align="center" border="0" cellspacing="0" cellpadding="3"><tr><td>Name</td><td><input type="text" name="name" value="<?php echo $row['name']; ?>" maxlength="30"></td></tr><tr><td>Location</td><td><input type="text" name="location" value="<?php echo $row['location']; ?>" maxlength="30"></td></tr><tr><td>Age</td><td><input type="text" name="age" value="<?php echo $row['age']; ?>" maxlength="30"></td></tr><tr><td><input type="submit" value="Submit" name="submit"><td></tr></table></form><?php } else { $name = $_POST['name']; $location = $_POST['location']; $age = $_POST['age']; mysql_query("UPDATE `members` SET `name` = '$name', `location` = '$location', `age` = '$age' WHERE id = '$id'"); echo "Profile updated !"; }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65832 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 Ok ,but I dont need to use a database to edit their profiles, im doing it now... except with one giant <textarea> that edits their whole page, i want textboxes that edit little snippets. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65833 Share on other sites More sharing options...
hackerkts Posted July 30, 2006 Share Posted July 30, 2006 If you stored their informations inside database, then you need to update the database to make any changes. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65835 Share on other sites More sharing options...
techiefreak05 Posted July 30, 2006 Author Share Posted July 30, 2006 OMG i get it. lol ;) youre telling me how to update their information, like password and email and stuff, but thats not what im after! LMAO. Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65836 Share on other sites More sharing options...
hostfreak Posted July 30, 2006 Share Posted July 30, 2006 What exactly are you after then? Quote Link to comment https://forums.phpfreaks.com/topic/16008-snippet-editor-how-to/#findComment-65837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.