Jump to content

Irksome

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Everything posted by Irksome

  1. Hi all I have made a very basic website, using HTML with a little CSS thrown in as well. All it is made up of is one single table, with 3 rows (header, content, footer). The table width is 800px. When I hit print preview in Firefox, it cuts off a section of the page (to the right). Changing the scale to Shrink to Fit solves the issue, however I can't expect my site users to do that to print. Is there a way of getting round this? Any help would be greatly appreciated.
  2. Hi all, I have a basic SQL database containing a few text fields and a date field. The format for the date field is MM/DD/YYYY. The information is displayed in a simple table on a php page, ordered by date. This all works so far, but what I need is to display the MONTH in one column, and the DAY in the next. But, I also want the MONTH to be displayed as shorthand text, i.e. JAN, FEB etc. So this is how it is now: 01/01/2009 |text here 01/01/2009 |text here This is how I want it: JAN |04 |text here FEB |05 |text here Any help on how this is done would be greatly appreciated. Thanks.
  3. Ah that's worked, didn't think it would be so simple as that. Thanks a lot premiso.
  4. Oh I see, so would I apply the same as in the above bit of code to the page that displays the news? The code for that page is here: <html> <body> test page<br> <br> <?php session_start(); include 'config.php'; $result = mysql_query("SELECT * FROM scnews ORDER BY newsid DESC",$connect); //lets make a loop and get all news from the database while($myrow = mysql_fetch_assoc($result)) {//begin of loop //now print the results: echo '<b><font face=tahoma size=3 color="#5f88c0">'; echo $myrow['title']; echo "</b></span></font><font face=tahoma size=2><br><br>"; echo $myrow['text2']; echo "<br><hr width=220 align=left>Posted By: <b>"; echo $myrow['user']; echo "</b> On <i>"; echo $myrow['dtime']; echo "</i><br>"; }//end of loop ?> </body> </html>
  5. OK it's been a while since I've done any PHP so I'm trying to create a quick news script that contains user, title and text. Now the text field needs to be compatible with paragraphs, but it currently isn't. Everything comes out on one line. I know it's nl2br I need, but I've read through a few tutorials and code snippets but I just can't figure out how to apply it to my script. My code for my addnews.php page is here: <?php session_start(); include("config.php"); if($submit) {//begin of if($submit). $title = mysql_real_escape_string($_POST['title']); $user = mysql_real_escape_string($_POST['user']); $text2 = mysql_real_escape_string($_POST['text2']); $user = Trim(stripslashes($_POST['user'])); $text2 = Trim(stripslashes($_POST['text2'])); // nl2br $Body = ""; $Body .= "Comments: "; $Body .= $text2; $Body .= "\n"; //run query $result = mysql_query("INSERT INTO scnews (title, dtime, user, text2) VALUES ('$title',NOW(),'$user','$text2')",$connect); //success message. echo "<b>News entry added successfully!<br>"; echo "<meta http-equiv=Refresh content=0;url=index.php>"; }//end of if($submit). else {//begin of else ?> <br> <h3>Add news article</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> Title: <input name="title" size="40" maxlength="255"> <br> Logged on user: <b><?php echo $_SESSION['username']; ?></b> <input type="hidden" name="user" size="40" maxlength="255" value="<?php echo $_SESSION['username']; ?>"/> <br> Text:<br> <textarea name="text2" id="text2" class="ed"></textarea> <br> <input type="submit" name="submit" value="Add News Article"> </form> <? }//end of else ?> If anyone could sort of point me in the right direction here it would be greatly appreciated. Thanks.
  6. Oh sorry forgot about the code <?php include("config.php"); if($submit) {//begin of if($submit). $title = mysql_real_escape_string($_POST['title']); $user = mysql_real_escape_string($_POST['user']); $text2 = mysql_real_escape_string($_POST['text2']); //run query $result = mysql_query("INSERT INTO scnews (title, dtime, user, text2) VALUES ('$title',NOW(),'$user','$text2')",$connect); //print success message. echo "<b>Thank you! entry added successfully!<br>"; echo "<meta http-equiv=Refresh content=0;url=index.php>"; }//end of if($submit). else {//begin of else ?> <br> <h3>Add news article</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> Title: <input name="title" size="40" maxlength="255"> <br> Name: <input name="user" size="40" maxlength="255"> <br> Comments: <textarea name="text2" rows="7" cols="30"></textarea> <br> <input type="submit" name="submit" value="Sign Guestbook"> </form> <? }//end of else ?>
  7. It's been a while since I've done any PHP, so I'm making a simple guestbook script just to get back into the swing of it. I've managed to get it working just fine except for one thing. When you type some text in the text field that has multiple lines and submit it, it will produce the entry all on one line. For example this entry: Testing 123 Testing 123 Testing 123 Will appear as: Testing 123 Testing 123 Testing 123 I don't even know what the process is called to solve this. I can do it by entering HTML into the text box but that's something I'd rather avoid. Any help on this would be greatly appreciated.
  8. Facebook is hosted in a data centre, which is a building full of rack servers. They are probably running on about 350 servers by now. I would suggest just buying some decent hosting. The cost of the hosting will be less than the cost of running your own server, with electricity bills etc. Ask your members to donate to the costs of running the site, or create premium membership that they need to pay for.
  9. This is what I have for my member section, more or less the same as what you're asking but you'll need to customise it to your needs. <?php session_start(); // If users aren't logged in then display error message and exit. if($_SESSION['user_level'] == 0){ echo "You do not have access to this section. Please log in first.";exit; } // Users logged in successfully, display options. echo "Welcome ". $_SESSION['username'] ."!<br /><br />"; echo "Member Options"; echo "Member Option 1"; echo "Member Option 2"; echo "Member Option 3"; // Special options for admins and developers. if($_SESSION['user_level'] == admin){ include "admin/adminoptions.php"; } if($_SESSION['user_level'] == dev){ include "admin/devoptions.php"; } echo "<a href=logout.php>Logout</a>"; ?> This is assuming you already have a login script set up, as this requires sessions from the login script. Just change them to suit your needs.
  10. Ah how could I have missed that? Seems I'm getting a blank page now though, no errors or anything. Do you know what this could be down to? Thanks.
  11. Hi all, I'm in the process of making a user management script, and have come to a dead end here. I have the following code for the page that lists the current user accounts registered in the database. <?php session_start(); require "../db.php"; require "../global.php"; switch ($_SESSION['user_level']) { default:echo $text['adminperms']; exit; case 4: case 5: $result = mysql_query("SELECT * FROM com_users WHERE user_level > 4 ORDER BY userid DESC",$connection) or die(mysql_error()); $user_list = "<ul>"; while ($myrow = mysql_fetch_assoc($result)) { $userid = $myrow['userid']; $username = $row['lname']; $user_level = $row['fname']; $user_list .= "<li><a href=\"edit_user.php?userid=$userid\">$username</a>"; } $user_list .= "</ul>"; } ?> The problem is, I'm getting logged out whenever this page is accessed, therefore getting my "No admin permissions" error message. I've tried running this script without the permission requirements, but still no joy, just a blank page. If anyone could point out what's wrong with that code then I would be ever so grateful. Thanks.
  12. Hi, yes I've tried that many times over, but all I get is parse errors. The one time I did get an actual result, it brought up a seperate box for each username. I want them all in one box. I guess I'm doing something wrong like missing out quotes or semicolons somewhere. Here is the code I have: <?php session_start(); require "../db.php"; require "../global.php"; switch ($_SESSION['user_level']) { default:echo $text['adminperms']; exit; case 4: case 5: $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connection)or die(mysql_error()); while($myrow = mysql_fetch_assoc($result)) echo "<form action=\"edit_user.php?userid=$myrow[userid]\" method=get><select name=select size=10> <option>"; { echo $myrow['username']; } echo "</option></select> <input type=submit name=Submit value=Submit></form>"; // Now print the options } echo '<br>'; ?> Can anyone see what's wrong here?
  13. Hi all, I have a rather complicated issue here and can't seem to resolve it even after a full hour of working at it. I have an admin section on my site, and under the user management section I made it present a basic list of users with a link next to each username to edit thier profiles. Now, what I want is a listbox, with all of the usernames in it, and a button next to it to edit the selected user's profile. The code for my current page is below: <?php include("../db.php"); //load all users from the database and then ORDER them by userid $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connect); //Make loop and get all users from the database while($myrow = mysql_fetch_assoc($result)) {//begin of loop //Results echo $myrow['username']; // Link to edit user echo "<br><a href=\"edit_user.php?userid=$myrow[userid]\">Edit User</a>"; }//end of loop ?> How can I convert this to a listbox with a button next to it leading to "edit_user.php"? Any help would be very much appreciated.
  14. Hi all, I'm making a website with an admin section, and one facet of that is user management. I've made a script for this task, but I want it to be accessable only to people with user level 4 or 5. Here's the code for the script. At present, it isn't accessable to anybody, even level 4 and 5 users. <?php require '../db.php'; require '../global.php'; switch ($_SESSION['user_level']) { case 5:echo $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connection)or die(mysql_error()); while($myrow = mysql_fetch_assoc($result)) {//begin of loop //now print the results: echo $myrow['username']; echo "<a href=\"edit_user.php?userid=$myrow[userid]\">Edit User</a>"; echo '<br>'; }//end of loop ; case 0:echo $text['adminperms'];exit; case 1:echo $text['adminperms'];exit; case 2:echo $text['adminperms'];exit; case 3:echo $text['adminperms'];exit; } ?> Could anyone point me in the right direction here? Thanks.
  15. Hi, thanks for the quick replies. Got it sorted now thanks to Caesar's solution, thanks again!
  16. Hi all, I'm in the process of making a website with a login and admin section, but I've gotten stuck at permissions for it. I have it set up so it detects your user level, and if you aren't admin user level, it exits the script. This works fine, but when it exits the script, it cuts off the rest of my website layout as well. So I'm left with half a site. My question is: if I exit a script, is there a piece of code I can use to bring back the rest of the site? Hope that makes sense.
  17. Ahh that solved it! Thanks for the quick responses guys.
  18. Hi all, I've just made a small admin script to manage the user accounts on my website. I get the following error whilst accessing the page however: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /public_html/com/admin/users.php on line 7 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/com/admin/users.php on line 9 The code for the page is below. To be honest I can't see what's wrong with it: <?php // load the configuration file. include '../db.php'; $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connect); while($myrow = mysql_fetch_assoc($result)) {//begin of loop //now print the results: echo $myrow['user_name']; echo "<a href=\"edit_user.php?userid=$myrow[userid]\">Edit User</a>"; }//end of loop ?> Any help on this would be very much appreciated. Thanks.
  19. Hi all. I've just started to make my own forum as a hobby, but have ran into this problem: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/public_html/forum/viewthread.php on line 45 This shows up whenever I try to view a thread. The code for the page is as follows: <?php require '../db.php'; $tbl_name="comforum_threads"; // Table name // get value of id that sent from address bar $id=$_GET['id']; $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="93%"><? echo $rows['datetime']; ?></td> <td width="7%"> </td> </tr> </table> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="8" valign="top"><? echo $rows['name']; ?></td> <td width="83%" valign="top"><p><? echo $rows['thread']; ?><hr></p> <p><? echo $rows['detail']; ?></p> </td> </tr> </table> <?php $tbl_name2="comforum_posts"; // Switch to table "comforum_posts" $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'"; $result2=mysql_query($sql2); while($rows=mysql_fetch_array($result2)){ ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="82%"><? echo $rows['a_datetime']; ?></td> <td width="18%"><? echo $rows['a_id']; ?></td> </tr> </table> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td width="8" valign="top"><? echo $rows['a_name']; ?> </td> <td width="83%" valign="top"><p><? echo $rows['thread']; ?><hr></p> <p><? echo $rows['a_answer']; ?></p></td> </tr> </table> <? } $sql3="SELECT view FROM $tbl_name WHERE id='$id'"; $result3=mysql_query($sql3); $rows=mysql_fetch_array($result3); $view=$rows['view']; // if have no counter value set counter = 1 if(empty($view)){ $view=1; $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'"; $result4=mysql_query($sql4); } // count more value $addview=$view+1; $sql5="update $tbl_name set view='$addview' WHERE id='$id'"; $result5=mysql_query($sql5); mysql_close(); ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><p>Quick Reply</p></td> </tr> </table> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="postprocess.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td width="11%"><strong>Name</strong></td> <td width="83%"><input name="a_name" type="text" id="a_name" size="45"></td> </tr> <tr> <td><strong>Email</strong></td> <td><input name="a_email" type="text" id="a_email" size="45"></td> </tr> <tr> <td valign="top"><strong>Message</strong></td> <td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td> </tr> <tr> <td> </td> <td><input name="id" type="hidden" value="<? echo $id; ?>"></td> </tr> <tr> <td> </td> <td width="6%"><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </td> </form> </tr> </table></td> </tr> </table> <p> </p> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> </tr> </table> I also have another error when replying to a thread: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/public_html/forum/postprocess.php on line 15 ERROR The code for that page is: <?php require '../db.php'; $tbl_name="comforum_posts"; // Table name // Get value of id that sent from hidden field $id=$_POST['id']; // Find highest answer number. $sql="SELECT MAX(a_id) AS Maxa_id FROM $tbl_name WHERE question_id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); // add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 if ($rows) { $Max_id = $rows['Maxa_id']+1; } else { $Max_id = 1; } // get values that sent from form $a_name=$_POST['a_name']; $a_email=$_POST['a_email']; $a_answer=$_POST['a_answer']; $datetime=date("d/m/y H:i:s"); // create date and time // Insert answer $sql2="INSERT INTO $tbl_name(question_id, a_id, a_name, a_email, a_answer, a_datetime)VALUES('$id', '$Max_id', '$a_name', '$a_email', '$a_answer', '$datetime')"; $result2=mysql_query($sql2); if($result2){ echo "Successful<BR>"; echo "<a href='viewthread.php?id=".$id."'>View your answer</a>"; // If added new answer, add value +1 in reply column $tbl_name2="forum_question"; $sql3="UPDATE $tbl_name2 SET reply='$Max_id' WHERE id='$id'"; $result3=mysql_query($sql3); } else { echo "ERROR"; } mysql_close(); ?> I have no idea why it's doing it. Could anyone shed any light on this subject? Thanks.
  20. Hi, I'm fairly basic with PHP at the moment, but I have one small question. Currently, I have three files in my test section. Index.php, members.php and login.php. Now I want all of this to be on one page. FOr example, when you want to view the memberlist, instead of going to members.php you go to index.php?action=members. I don't know what it's actually called, but could someone shed some light on a quick and easy way to do this? Any help would be most appreciated. Thanks.
  21. Might sound silly, and I'm by no means an expert with PHP, but perhaps changing this: <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> To this: <form action="logincheck.php" method="post"> Try that. Like I said I could be entirely wrong, but that's the way my login system works.
  22. I'm currently using ID's in my user profiles, but is updater_id == db_id the actual code I need to use?
  23. Hi, I've just created a login system, and everything works fine. There's only one problem that I'm faced with at the moment, and that's the update profile page. Now when you appear on this page, the data form fields show up, containing your current username, email address, name etc. But when you click submit, it comes back with "Your email is already in use!". Yes it's in use, because the user is signed up with that address. What piece of code would I need to add in order to update the profile without getting an email in use error? Any help would be appreciated. Thanks.
  24. Hi all - I've become stuck in my attempt at making a register form for my site, so I have two quick questions to ask. 1) I have my register and login systems working fine, but the signup form only has one password box. I want to make a "confirm password" field as well, but have no real idea on how to do that. Maybe a quick Java script or something? Here's the code for the signup page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="form1" method="post" action="register.php"> <table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr> <td width="24%" align="left" valign="top">First Name</td> <td width="76%"><input name="first_name" type="text" id="first_name"></td> </tr> <tr> <td align="left" valign="top">Last Name</td> <td><input name="last_name" type="text" id="last_name"></td> </tr> <tr> <td align="left" valign="top">Email Address</td> <td><input name="email_address" type="text" id="email_address"></td> </tr> <tr> <td align="left" valign="top">Desired Username</td> <td><input name="username" type="text" id="username"></td> </tr> <tr> <td align="left" valign="top">Desired Password</td> <td><input name="password" type="password" id="password"></td> </tr> <tr> <td align="left" valign="top">Information about you</td> <td><textarea name="info" cols="45" rows="5" id="info"></textarea></td> </tr> <tr> <td align="left" valign="top"> </td> <td><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form> </body> </html> 2) I have tried to create an update profile page, but it has just failed miderably. I get SQL errors every time I click submit. No idea what's wrong here: <? include 'db.php'; // Define variables $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email_address = $_POST['email_address']; $password = $_POST['password']; $info = $_POST['info']; $userid = $_POST['userid']; /* stripslash check*/ $first_name = stripslashes($first_name); $last_name = stripslashes($last_name); $email_address = stripslashes($email_address); $info = stripslashes($info); $userid = stripslashes($userid); $password = stripslashes($password); /* Error checking */ if((!$first_name) || (!$last_name)){ echo 'You did not submit the following required information! <br />'; if(!$first_name){ echo "First Name is a required field. Please enter it below.<br />"; } if(!$last_name){ echo "Last Name is a required field. Please enter it below.<br />"; } include 'update_profile.php'; // re-display form /* If everything is ok create the account. */ exit(); // exit script if error checking fials } /* Both error check passed. Update the profile. */ $db_password = md5($password); // Update DB $info2 = htmlspecialchars($info); $sql = mysql_query("UPDATE com_users SET first_name='$first_name', last_name='$last_name', email_address='$email_address', username='$username', password='$db_password', info='$info' WHERE userid='$userid' "); if(!$sql){ echo 'There has been an error updating your account. Please contact the webmaster.'; } else { $userid = mysql_insert_id(); } ?> Any help on these issues would be very much appreciated. Thank you.
  25. Hi, I am currently in the process of building a new website, and part of that involves a membership system. I have created the membership system, it all works and logs in fine. The only thing I am having trouble with is passwords. The first problem is that on my update profile page, I have made fields for name, password, email and a a textbox to enter information about yourself. The problem is that I have configured it so that if you enter an email that is already in the database, it doesen't let you update your profile. But by default, your email is entered into the field, and when you click OK it just updates the database with whatever you have put in the fields. So what code would I type so that it doesen't say that your email is already in use? My second problem is the password field. When you type in a new password, it does not update the database with the new password. I think this is something to do with md5 encryption, but I don't know the exact code to put for that. My last problem is that I have made a lost password form where you type in your email address and it mails your password to you. I have no idea how to do this though. Any help on this would be greatly appreciated
×
×
  • 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.