Jump to content

neex1233

Members
  • Posts

    73
  • Joined

  • Last visited

    Never

Everything posted by neex1233

  1. How do I get the current logged in username or id using the Twitter API?
  2. I've been looking for a way to do this for a long time. I have a simple(ish) login system, and I want to allow users to login with Twitter or Facebook; How can I do this? I'm pretty experienced at PHP and MySQL, but I really don't understand the API of either of the social networking sites. If you only know how the API for one of the sites, that'd be great too.
  3. I fixed it. It was because I was using a URL include (for testing).
  4. I'm trying to include a file that contains code checking if a user is logged in, and if they are not it redirects them to the login form. The only problem is I don't think the script can check if the user is logged in if it is included. The funny thing is, I include the same exact script on the index of my site and it works fine, but when I incude it in a subdirectory file, it takes me to the login form. How can I fix this?
  5. Thank you guys so much! (I'm a n00b)
  6. It's not the actual making of the cookie that's the problem, it's the detection of the cookie. The cookie is made fine, I've checked in Add 'n Edit Cookies, but this code: <?php ob_start(); ob_clean(); $user = $_COOKIE['username']; if(isset($user)) { } else { header("location: /users/login.php"); } ?> isn't working. The code works on other pages, though.
  7. <?php /* $con make a connection with database */ $con=mysql_connect("localhost","root",""); //select database mysql_select_db("users"); /* Below two commands will store the data in variables came from form input */ $username=$_POST['user']; $password=$_POST['pass']; /* below two commands are sql injection which stops extra characters as input */ $user=mysql_real_escape_string($username); $pass=mysql_real_escape_string($password); $query=mysql_query("SELECT * FROM users where user='$user' AND pass='$pass' "); $count=mysql_num_rows($query); if($count==1) /* $count checks if username and password are in same row */ { echo "Login Successful"; $hour = 86400*365; /* $hour sets cookie storage time for 1 hour */ /* setcookie() function sets cookie after login */ ob_start(); ob_clean(); setcookie("username", $_POST['user']); setcookie("password", $_POST['pass']); header("location:/"); /* header() funtion redirect user to members page */ } else { echo "Username or password is incorrect"; } ?> And <?php ob_start(); ob_clean(); $user = $_COOKIE['username']; if(isset($user)) { } else { header("location: /users/login.php"); } ?> I know the cookies exist, because I looked in Add 'n Edit Cookies.
  8. It's not before any tags, and those tags aren't helping. I tried putting var_dump($_COOKIE); on the page I'm having the problem, and it doesn't do anything. However, if I do it on a different page, it works.
  9. This has been driving me crazy for hours! I am trying to set a cookie: setcookie("username", $_POST['user']); And for a while it wasn't working, then it started randomly working. Now, when I try to use if(isset($_COOKIE['username'])) PHP is saying the cookie does not exist. PLEASE help! Thanks.
  10. Btw, here's the errors: Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Codes\lyt.php on line 14 Warning: include(http://domain.com/codes/css/ff.php) [function.include]: failed to open stream: no suitable wrapper could be found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Codes\lyt.php on line 14 Warning: include() [function.include]: Failed opening 'http://domain.com/codes/css/ff.php' for inclusion (include_path='.;C:\php5\pear') in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Codes\lyt.php on line 14
  11. I'm trying to enable URL includes (allow_url_include), and I put "On" in the php.ini file, but it doesn't work. In the phpinfo() file, it also says they are off. Could somebody please help me?? Thanks.
  12. Thanks... Here is the send page <?php include("directory/lyt.php"); ?> <form action="send.php" method="post"> To:<br> <input type="text" name="to" size="7"/><br /> Subject:<br> <input type="text" name="subject" maxlength="20" size="18" /><br /> Message:<br> <textarea rows="4" cols="35" name="message" onFocus="this.value=''">Hi!</textarea><br> <input type="submit" value="Send!" /> </form> <br><br> <a href="URL"><small>« Back to Inbox</small></a>
  13. I have a PHP message script, and when I try to send a message (this just started happening today, all was fine before) it takes it to the delete form. On the send form page, there is a PHP include, which is the layout, and when the layout file is included the send button takes you to the delete form, but when the layout is not on the page, it takes you to the normal send page and works perfectly! Can anyone help me with this? It has never happened to me before!
  14. Hi, I want to echo a string in PHP, then erase it from the screen, but I can't find any way to do so. Is there a function or something? Thanks.
  15. I have this bit of code which is supposed to be selecting all records from a table. Here: $sql = " SELECT * FROM `messages` WHERE `to` = '$username' "; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $subject = $row['subject']; $from = $row['from']; $id = $row['id']; $time = $row['time']; } It works but it is only selecting one of the records that is to that user(first one), then when that one is deleted it is showing the next record to them. What should I do? I just want it to show all records in the table that have their username for the 'to' field. Thanks!
  16. neex1233

    CSS Buttons

    I would like the following code to apply to all of the buttons on my page without having to use the class="button". The code: input:button { color:#050; font: bold 84% 'trebuchet ms',helvetica,sans-serif; background-color:#fed; border: 1px solid; border-color: #696 #363 #363 #696; } Thanks.
  17. Hi, I made a comment script: <?php $con = mysql_connect("localhost","Username","Password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DB_Name", $con); $username = mysql_real_escape_string($_SESSION["username"]); $sql = " SELECT * FROM `users` WHERE username = '$username' LIMIT 0, 30 "; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $userlevel = $row['userlevel']; $userlevel = $row['name']; } if ( $userlevel == 5 ) { $table = "comments"; $em = "Hello there admin $name! Your comment has been posted!"; } if ( $userlevel == 4 ) { $table = "comments"; $em = "Hello, $username. Your comment has been posted and will not need to be approved by an admin."; } if ( $userlevel == 3 ) { $table = "ucomments"; $em = "Hi $username! Your comment will need to be approved by an admin before getting shown on the site."; } if ( $userlevel == 2 ) { $table = "ucomments"; $em = "Ooooh, $name, you just made it! If you were one userlevel lower, you wouldn't be able to post comments! Your comment must be approved though..."; } if ( $userlevel == 1 ) { echo "Sorry $name. Your userlevel is too low or you have been banned from posting comments."; die(); } $poster = mysql_real_escape_string($_SESSION["username"]); $text = mysql_real_escape_string($_POST["text"]); $userlevel = $_SESSION['userlevel']; putenv("TZ=America/Los_Angeles"); $time = date("g:i A"); $date = date("M/j/Y"); $for = mysql_real_escape_string($_POST["for"]); function doSmily($msg) { \\ Word filter. Not showing... return $msg; } $input = "$text"; $ntext = doSmily($input); $stext = mysql_real_escape_string($ntext); $sql="INSERT INTO $table (poster,text,time,date) VALUES ('$poster','$stext','$time','$date')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<strong><center>$em</center></strong>"; mysql_close($con); ?> And I get this error: Error: Unknown column 'poster' in 'field list' I've googled it and everything, but I still can't figure out what's wrong. Could anybody help me? Thanks!
  18. Actually, that script doesn't work. I tried it.
  19. So where do I put that?
  20. Hey everyone, I have a PHP comment script (below) and I would like to make it so if the user didn't select an article to view, it shows all of them. It uses the get function to display what they would like, and I would like to make it so if the ?id=1 isn't on the URL, it shows all of the news. Here is the script: <?php $con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ' . mysql_error()); mysql_select_db("DB_Name", $con); if(isset($_GET['id']) && is_numeric($_GET['id'])) if($_GET['id'] == 0) { // Check. echo "Invalid!"; die(); } { $id = (int) $_GET['id']; $sql = 'SELECT * FROM `news` WHERE id='.$id; $result = mysql_query($sql); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $text = stripslashes($row['text']); $text = stripslashes($row['text']); $title = stripslashes($row['title']); $title = stripslashes($row['title']); ?> <h2><?php echo "<a href='?id=$id'>"; ?><?php echo $title; ?></a></h2> Posted by <?php echo $row['poster']; ?> on <?php echo $row['date'] . ' at ' . $row['time']; ?> <p><?php echo $text;?></p> <?php } } ?> You can see the 'Check.' comment which is my attempt to do what I wanted to do, which didn't work. Could anybody help me with this? Thanks.
  21. Wait, nevermind. I just fixed the code. Here is my final one: <?php $allow = array ('5');include ("/home/username/public_html/folder/protect.php"); ?> <title>News</title> <?php $con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ' . mysql_error()); mysql_select_db("DB_Name", $con); if(isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $sql = 'SELECT title, poster, text, time, date FROM `news` WHERE id='.$id; $result = mysql_query($sql); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); ?> <h1><?php echo $row['title']; ?></h1> <p>Posted by: <?php echo $row['poster']; ?> On <?php echo $row['date'] . ' ' . $row['time']; ?> <p><?php echo $row['text'];?></p> <?php } } ?> Thanks for your help wildteen!!
  22. Okay. Also the final code I am using: <?php $allow = array ('5');include ("/home/username/public_html/folder/protect.php"); ?> <title>News</title> <?php $con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ' . mysql_error()); mysql_select_db("DB_Name", $con); if(isset($_GET['id'])) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $sql = 'SELECT title, poster, text, time, date FROM `news` WHERE id='.$id; $result = mysql_query($sql); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); ?> <h1><?php echo $row['title']; ?></h1> <p>Posted by: <?php echo $row['poster']; ?> On <?php echo $row['date'] . ' ' . $row['time']; ?> <p><?php echo $row['text'];</p?> <?php } } ?> Gives me this error: Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/username/public_html/folder/folder/folder/show_news.php on line 7
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.