Jump to content

Irksome

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Irksome's Achievements

Member

Member (2/5)

0

Reputation

  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!
×
×
  • 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.