papillonstudios Posted June 3, 2009 Share Posted June 3, 2009 Ok i have a form to submit News. so the title, username, date and body. but like always i check the table for the data enter to make sure its right but when the form submits it just out in the $username variable. so i'm guessing here when i look at the news which ever user i'm logged in as will be displayed. how do i make the form enter the username string of the user from the username variable to if you are logged in as admin and you post something it shows in the database that admin posted it. heres my form <form method="post"> <input type="hidden" name="username" value="$username"> <table width="50%"> <tr><td>Title <input type="text" class="textfield" name="title"></td></tr> <tr><td>Date <input type="text" class="textfield" name="date" /> </td></tr> <tr><td></td></tr> <tr><td>Body <textarea cols="40" rows="10" class="textbox" name="body"></textarea></td></tr> <tr><td><input type="submit" name="submit" value="Post News"></td></tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/ Share on other sites More sharing options...
Maq Posted June 3, 2009 Share Posted June 3, 2009 how do i make the form enter the username string of the user from the username variable to if you are logged in as admin and you post something it shows in the database that admin posted it. I guess I'm confused here. Check the database to see what group the '$username' is in? Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-848823 Share on other sites More sharing options...
papillonstudios Posted June 3, 2009 Author Share Posted June 3, 2009 ok heres what i want it to do. if im logged in as admin lets say and i post some news. when a guest comes to the site and users logged in i want it to say admin not the users username. so how do i get the form to submit the value of $username Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-848825 Share on other sites More sharing options...
Maq Posted June 3, 2009 Share Posted June 3, 2009 so how do i get the form to submit the value of $username That's exactly what you're doing here: Where does the value of '$username' come from? Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-848830 Share on other sites More sharing options...
papillonstudios Posted June 3, 2009 Author Share Posted June 3, 2009 it comes from the config.php buts it's called $uName but still i trested it by echo $username (after pulling it from the database table news and it displays $username which is in the field in the table Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-848850 Share on other sites More sharing options...
keeps21 Posted June 3, 2009 Share Posted June 3, 2009 change <input type="hidden" name="username" value="$username"> to <input type="hidden" name="username" value="<?php echo $username;?>"> [/php Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-848855 Share on other sites More sharing options...
benphelps Posted June 3, 2009 Share Posted June 3, 2009 You can use this if short tags is on: <input type="hidden" name="username" value="<?=$username?>"> Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-848887 Share on other sites More sharing options...
Maq Posted June 4, 2009 Share Posted June 4, 2009 Did I really not see that? wow... In my defense the OP didn't state that was the problem. Do you still need to show that 'admin' posted the message? Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-849211 Share on other sites More sharing options...
papillonstudios Posted June 5, 2009 Author Share Posted June 5, 2009 i got it all working fine thanks Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-849692 Share on other sites More sharing options...
Maq Posted June 5, 2009 Share Posted June 5, 2009 i got it all working fine thanks I'll mark this as solved for you but in the future there is a "Topic Solved" button in the bottom left right above "Quick Reply". Quote Link to comment https://forums.phpfreaks.com/topic/160830-solved-username-post/#findComment-849958 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.