Jump to content

alexcrosson

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

alexcrosson's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well there isn't any empty lines that i can see after the ?>
  2. This is the error I get: [b]Warning: Cannot modify header information - headers already sent by (output started at /home/totallyc/public_html/login/users.php:18) in /home/totallyc/public_html/login/add_user.php on line 16[/b] Here is my code starting at line 16: [code]header("Location: users.php");[/code] I need to redirect after a user has been added and i'm having trouble doing it.
  3. Now that, that part of the site works. Would you guys know how to do the [b]Edit Entry[/b] Link?
  4. The way alpine did it work for me. Thanks guys i really get a lot help around here.. thats why i love this site soo much.  ;D
  5. First of All here is my code: [code]   $result = mysql_query("SELECT * FROM blog ORDER BY date DESC") or die(mysql_error()); while($row=mysql_fetch_array($result)) { $x = mysql_query("SELECT id FROM blog"); echo "<div id=\"blog\">\n"       ."<h1>{$row['title']}</h1>\n"       ."<p>{$row['content']}</p><br/>\n"       ."<h2>Edit Entry | <a href=\"?a=delete&amp;d=$x\">Delete Entry</a></h2>\n"       ."</div>\n"; }[/code] I basicly trying to create a way for user to delete blog posts on my site. There is a loop which pulls all of the blog entries and puts them into html. I want to asign value to the "[b]Delete Entry[/b]" link which will give the id of the query being selected. To do this is use [b]$x[/b] to store the id of the resulting blog. My code is wrong, i know this but I'm hoping someone can tell me how to re-write:[code] $x = mysql_query("SELECT id FROM blog");[/code]Into something that will give the value of the id field. It may be hard to explain so feel free to ask questioins if you don't understand
  6. Oh oh.. I see. sorry for misunderstanding you. THanks for your help.
  7. If i declare $x inside loop won't it reset x to 1 everytime?
  8. THis is the error i get [b] Parse error: parse error, unexpected T_WHILE in /home/totallyc/public_html/login/blog.php on line 37[/b] Line 37 is : [quote]while($row=mysql_fetch_array($result)) {[/quote]
  9. I'm trying to assign values to each Delete Entry link. But i'm having some trouble doing it. Here is my code: [code]  <?php   switch($_GET['a']) { case "add_entry":   include("add_entry.php"); break; default:   $result = mysql_query("SELECT * FROM blog ORDER BY date DESC") or die(mysql_error()); $x = 1 while($row=mysql_fetch_array($result)) { $blog_array[$x] = $x echo "<div id='blog'><h1>". $row['title']. "</h1><p>". $row['content']. "</p>". "<br /><h2>Edit Entry | <a href="?a=delete?d=$x">Delete Entry</a>". "</h2></div>"; $x = $x + 1 } break; } ?>[/code]
  10. Okay i'll try to explain this as best as possible. There is the main.php page. and when you click a link name Add Entry, it includes add_entry.php Here is the add_entry.php code: [code]<?php if(isset($_POST['submit'])); { echo "This seems to work" } ?> <h2>Add Entry</h2> <form name="Add Entry" action="<?php echo $_POST['a']=add_entry; $_SERVER['PHP_SELF'];?>" method="POST"> <label for="title">Title:</label> <input name="blgtitle" id="blgtitle" type="text" /> <label for="content">Content:</label> <textarea name="blgcontent" cols="35" rows="4" id="blgcontent"></textarea> <p> <input type="submit" name="submit" value="Submit" /> </p> </form>[/code] Its pretty basic. This is wear I will be able to add blog entries but i have some problems. When my site includes this page it gives me the following output: [quote]This seems to work. Add Entry Title: Content:[/quote] The "This seems to work" part should only display when the form has been submited right? And the <? $_SERVER['PHP_SELF'];?> won't work because it reloads the main.php page, not the add_entry.php This may seem really complicated but maybe you can help.
  11. Thanks that did the trick. but do u think you could explain it?
  12. OKay i have my database set up like so: [b]id        username              password                firstname              lastname[/b] 1          sample                    ck3949                John                      DOE Someone can login and it checks weather its the right password and then redirects them to a diferent page. On that page I want to have a message Saying "Welcome John", meaning that i need to pull the firstname out of the row of the user that is logged in. Heres my code: [code]$query = mysql_query("SELECT firstname FROM users WHERE username='$user'") or die ("Can't execute: " . mysql_error()); $name = $query ?>   <h1>Welcome <? print $name; ?>,</h1>[/code] And i don't get any errors but my output is: [b]Welcome Resource id #4[/b] Any idea?
  13. wow that did it . thanks wildteen and huggie and all others that helped  ;D
  14. same error : [b]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/totallyc/public_html/login/index.php on line 27[/b]
  15. [code]<?php //check that the user is calling the page from the login form and not accessing it directly //and redirect back to the login form if necessary //check that the form fields are not empty, and redirect back to the login page if they are if (isset($_POST['Login'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $result = "Username or Password field appear to be empty."; } else { // Convert Posted Data to Variables $user = $_POST['username']; $pass = $_POST['password']; $dbHost = "localhost"; $dbUser = "**"; $dbPass = "**"; $dbDatabase = "****"; // Connect to Database $conn = mysql_connect($dbHost,$dbUser,$dbPass) or die ("Unable to connect to Database"); mysql_select_db($dbDatabase); $query = mysql_query("SELECT * FROM users WHERE username='$user' AND password='$pass'"); $result = mysql_fetch_array($query); //check that at least one row was returned if (mysql_num_rows($result) != 0) { //start the session and register a variable session_start(); session_register('username'); //successful login code will go here... $error = "Success"; //we will redirect the user to another page where we will make sure they're logged in //header( "Location: checkLogin.php" ); } else { //if nothing is returned by the query, unsuccessful login code goes here... $error = 'Incorrect login name or password. Please try again.'; } } } ?>[/code]
×
×
  • 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.