Porkie Posted May 27, 2010 Share Posted May 27, 2010 Ive used a bit of a script to help me with being able to post messages from my website to my twitter. The problem is a only want certain people to be able to access it with a password field. So if they were to get the password and type it it then they could post but without the password they couldnt. So basically they type in there message and a password, if the password is correct then post is created otherwise error. Any help will be appreciated. <?php /* ---------------------------------------- */ // Change these parameters with your Twitter // user name and Twitter password. /* ---------------------------------------- */ $twitter_username ='yourTwitterUserName'; $twitter_psw ='yourTwitterPassword'; /* ---------------------------------------- */ /* Don't change the code belove /* ---------------------------------------- */ require('twitterAPI.php'); if(isset($_POST['twitter_msg'])){ $twitter_message=$_POST['twitter_msg']; if(strlen($twitter_message)<1){ $error=1; } else { $twitter_status=postToTwitter($twitter_username, $twitter_psw, $twitter_message); } } /* ---------------------------------------- */ ?> I have created the field on the form page. what would i need to do on this page to check the password field is correct before posting? Link to comment https://forums.phpfreaks.com/topic/203143-creating-a-password-field-and-linking-up/ Share on other sites More sharing options...
-Karl- Posted May 27, 2010 Share Posted May 27, 2010 <?php //Variables $twitter_username = 'yourTwitterUserName'; $twitter_psw = $_POST['password']; $twitter_message=$_POST['twitter_msg']; echo '<form method="post" action=""> <input type="password" name="password"> <input type="text" name="twitter_msg"> <input type="submit" name="submit" value="Submit"> </form>'; if (!empty($_POST['password']) && !empty($_POST['twitter_msg'])) { //Require the API require('twitterAPI.php'); if(isset($_POST['twitter_msg'])){ if(strlen($twitter_message)<1){ $error=1; } else { $twitter_status=postToTwitter($twitter_username, $twitter_psw, $twitter_message); } } } else { echo 'Password and message cannot be left blank.'; } ?> Something like that? Link to comment https://forums.phpfreaks.com/topic/203143-creating-a-password-field-and-linking-up/#findComment-1064377 Share on other sites More sharing options...
Porkie Posted May 27, 2010 Author Share Posted May 27, 2010 i arent sure whether that will work because the code worked but now ive editted the form on this page to have a password field which will be pre set and if the password doesnt match up with the preset password then it will not post the comment otherwise it will. <!-- Send message to Twitter --> <?php if(isset($_POST['twitter_msg']) && !isset($error)){?> <div class="msg"><?php echo $twitter_status ?></div> <?php } else if(isset($error)){?> <div class="msg">Error: please insert a message!</div> <?php }?> <p><strong>What are you doing?</strong></p> <form action="insertTwitterMsg.php" method="post"> <input name="twitter_msg" type="text" id="twitter_msg" size="40" maxlength="140"/> [b]<input name="password type="text" id="password" size="10"[/b] <input type="submit" name="button" id="button" value="post" /> </form> Link to comment https://forums.phpfreaks.com/topic/203143-creating-a-password-field-and-linking-up/#findComment-1064384 Share on other sites More sharing options...
-Karl- Posted May 27, 2010 Share Posted May 27, 2010 Show me your full code. I'll change it around a bit. Link to comment https://forums.phpfreaks.com/topic/203143-creating-a-password-field-and-linking-up/#findComment-1064386 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.