Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: steve51184 on January 27, 2010, 09:23:47 PM

Title: how do i add peoples usernames to a script?
Post by: steve51184 on January 27, 2010, 09:23:47 PM
hey all i have this script and i want to know is there a way i can have the value="" bit of the 'from' imput box auto filled with the users username?

Code: [Select]
<form action="http://pushme.to/myusername/" method="POST"><input type="hidden" name="_encoding" value="UTF-8"></input>Message: <input type="text" name="message"> From: <input type="text" name="signature" value=""/> <input type="submit" value="Push"/></form>
Title: Re: how do i add peoples usernames to a script?
Post by: hadesflames on January 27, 2010, 09:35:04 PM
Assuming this is a custom php page, include SSI.php then global $context and you would have something like:

Code: [Select]
<?php
require_once('path/to/SSI.php');
global 
$context;

echo 
'<input type="text" name="name" value="' $context['user']['username'] . '" />';
?>
Title: Re: how do i add peoples usernames to a script?
Post by: steve51184 on January 27, 2010, 09:41:34 PM
perfect thank you :)
Title: Re: how do i add peoples usernames to a script?
Post by: hadesflames on January 27, 2010, 09:57:01 PM
Glad I could help =]
Title: Re: how do i add peoples usernames to a script?
Post by: steve51184 on January 30, 2010, 02:04:29 PM
hey if this is for usernames how do i show display names?

Code: [Select]
$context['user']['username']