Jump to content


Photo

Snippet Editor - HOW TO!?!?


  • Please log in to reply
29 replies to this topic

#1 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 09:54 AM

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. how can i add a pre defined layout and add little snippets they can edit without the knowledge of HTML??? (yeah. like MySpace..)
Link shortener with advanced, detailed statistics:

http://tyny.us/

#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:07 AM

You can try bbcodes, just like every forums does.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#3 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:09 AM

How can I do that ... sorry for the dumb qauestion .. if heard of that before I jsut don't know what it is!
Link shortener with advanced, detailed statistics:

http://tyny.us/

#4 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:15 AM

You can try to search around for bbcode, btw.. This is the function I'm using
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;
}

Useage:
<?php
echo bbcode("[b]Bold[/b]");
?>


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#5 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:23 AM

How would I incorporate that into my site ... That makes no sense....
Link shortener with advanced, detailed statistics:

http://tyny.us/

#6 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:26 AM

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.
Link shortener with advanced, detailed statistics:

http://tyny.us/

#7 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:29 AM

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.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#8 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:32 AM

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...
Link shortener with advanced, detailed statistics:

http://tyny.us/

#9 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:38 AM

Are all your members information stored in database ?

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#10 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:40 AM

Yes. a MySQL DB, yeah, it has their Username, Password(md5 encrypted) and e-mail address.
Link shortener with advanced, detailed statistics:

http://tyny.us/

#11 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:48 AM

Then before those textboxes, you put something like $_GET['id'];
Then do a sql query, example:
$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);

Next, at the textboes, remember to put value="$row['username]''" etcs..
Then the person go to http://domain/editprofile.php?id=1

It will display the textbox with all his informations.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#12 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:51 AM

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....
Link shortener with advanced, detailed statistics:

http://tyny.us/

#13 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:52 AM

Have you done scripting the html part (those text boxes) ?

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#14 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:53 AM

No, but It'll take me 5 seconds to make the boxes..lol
Link shortener with advanced, detailed statistics:

http://tyny.us/

#15 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 30 July 2006 - 10:55 AM

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
Email: infront so I know :P

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#16 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 10:56 AM

Ok, ill get back to you in  a bit.
Link shortener with advanced, detailed statistics:

http://tyny.us/

#17 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 30 July 2006 - 11:01 AM

You also need to update the mysql database with the new information they enter. Heres an example of what you would do:

<?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>&nbsp;<input type='text' name='example1' value='<?php echo "$example1"; ?>'>
</td>
</tr>
<tr>
<td>Example2:</td>
<td>&nbsp;<input type='text' name='example2' value='<?php echo "$example2"; ?>'>
</td>
</tr>
<input type='hidden' name='id' value='<?php echo "$id"; ?>'>
</form>
</table>
<?php
}
?>

Change the "table" to your mysql table, then change the examples to the rows your using etc.

#18 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:03 AM

<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>

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**
Link shortener with advanced, detailed statistics:

http://tyny.us/

#19 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 30 July 2006 - 11:04 AM

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..
Link shortener with advanced, detailed statistics:

http://tyny.us/

#20 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 30 July 2006 - 11:12 AM

Alright, here is how you would call the information for them to edit:

<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>&nbsp;<input type='text' name='name' value='<?php echo "$name"; ?>'></td>
</tr>
<tr>
<td>Location:</td>
<td>&nbsp;<input type='text' name='location' value='<?php echo "$location"; ?>'></td>
</tr>
<tr>
<td>Age:</td>
<td>&nbsp;<input type='text' name='age' value='<?php echo "$age"; ?>'></td>
</tr>
<input type='hidden' name='id' value='<?php echo "$id"; ?>'>
</form>
</table>

From there add what you need, to update it how you want.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users