Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by chibineku

  1. I believe the problem is that the forms send a variable called page_mode, which is either login or register, but when you are checking what the user is doing in func.php, you are checking for $_POST['login'] or $_POST['register'] instead of checking if $_POST['page_mode'] == 'login' or $_POST['page_mode'] == 'register'.

  2. For future reference, you cannot use shortcut expressions in JavaScript conditionals. The correct version of the line you attempted would be this:
    if (location == "http://www.alarm-selskabet.dk/drupal/" || location == "http://alarm-selskabet.dk/drupal/")

    That's something I tried in my early days and quickly learned my lesson. Programming sometimes feels a bit too much like natural English and it can be hard to spot the errors when they read right.
  3. You can create password protection on certain pages or directories using Apache's .htaccess file. First, you have to find out if your server is Apache. If it is, then here is a handy tutorial.Doing it with a server side language is more complicated, but it gives nicer results if you only want to restrict access to portions of web pages instead of entire pages or directories. It's a lot more complex, so I'll let you look at that tutorial to see if it fits your needs first.

  4. Another idea is to pass some variable from one page to another, stored in the session or POSTed, so that pages can only be accessed sequentially. For example, at the top of page one you might have

    <?php session_start(); $_SESSION["page"] = 1; ?>

    Then at the top of page two, you need to interrogate the page variable to see where you are:

    <?php session_start();if (!isset($_SESSION["page"]) || $_SESSION["page"] != 1) {//the user came directly without first going to page one, so we can either ship them to page one, issue a warning, or whatever we like - let's send them to page oneheader ("Location: page1.php");exit;}//now we can update the page variable to reflect page two$_SESSION["page"] = 2;?>

  5. Anybody with a browser COULD resend the e-mail, which is why it doesn't usually work like that. In the example I gave, I imagined that you were creating an online e-mail service so that the sender, recipient and content would be different each time. If you want to create a system for allowing you to send HTML mail to a mailing list, then first password restrict access to that page, and create a template that allows you to paste HTML into the message body and a space for creating a new subject line, that way you won't need to create a whole new version of the contact page each time you want to send an HTML e-mail. Your steps for sending an HTML e-mail are correct as far as they go, but have no flexibility or way of preventing abuse. I tried out your form and added some HTML tags and it worked perfectly, by the way.

  6. Okay, it's a bit clearer now. Do you know how to transfer form data with PHP using the get/post methods?Let's make a sample script that lets someone e-mail any address they like using your online form, for practice.A basic form page, let's call it contact_form.php (though it could be .html), might look like:

    <html><head><title>Contact Form</title></head><body><form method="post" action="contact.php"><label for="from">Your E-mail Address:</label><input type="text" name="from" id="from" /><label for="to">Recipient:</label><input type="text" name="to" id="to" /><label for="subject">Subject:</label><input type="text" name="subject"  id="subject" /><label for="message">Message:</label><textarea name="message" id="message" rows="10" cols="40"></textarea><input type="submit" /></form></body></html>

    The POST method means that data sent to contact.php is not displayed in the URL as it would be if we used the GET method - generally better for sending private/lengthy data.When you hit submit, the data entered in the inputs is sent in an array, and you access the data like so:$_POST["emailAddress"] // will return whatever the user entered.You usually want to validate user entered data, but let's not for just now, for simplicity and since there aren't any real security concerns here.So, to make contact.php do the right thing, we'd modify it like so:

    <?php//simplify access to POSTED variables$from = $_POST["from"];$to = $_POST["to"];$subject = $_POST["subject"];$userMessage = $_POST["message"];// message$message = "<html><head><title>$subject</title></head><body><p>You were sent an HTML e-mail by $from</p><p>$userMessage</p></body></html>';// To send HTML mail, the Content-type header must be set$headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";// Additional headers$headers .= "From: $from" . "\r\n";$headers .= 'Cc: admin@globalfreeenterprise.com' . "\r\n";// Mail itmail($to, $subject, $message, $headers);//redirect user to some confirmation pageheader("Location: confirm_mail.html");exit;?>

    I don't know how helpful that is, but it should clarify the chain of events a bit.

  7. I'm not sure I understand the issue. Is it that you don't know how to link a contact form to the mail script, or that you don't know how to launch the mail script, or is it that the mail script, when launched, fails to send the e-mail?

  8. We are in the same thread. I was simply suggesting that instead of a menu that works by revealing a nested list when a top level list item is hovered over, the OP could make the nested list remain open onclick by using JavaScript. To answer the original problem, if the nested list appears with whitespace between it and the top level list item that the user hovered over to make it appear, then while moving the mouse cursor to the nested list, the nested list would vanish because the top level element is no longer being hovered over. There's a sentence for you.

  9. The concept of logging in has a few more facets to it than you may realize. First, you need a way for people to get login information (identifier (username/e-mail address) and password). So you need a registration process. This is typically a form which gathers the necessary information and stores it to a database table. When someone logs in using the login form, you have to compare the combination of identifier and password with the database to see if there's a match. If there is, you can write some value to the session / cookie arrays so that you can find information on the user any time you need to. What of this process are you already comfortable with?

  10. The alternative if you need to hold on to values which you can't have in the URL, such as passwords, is to store those details in the session variable, which is stored server side and is quite secure from prying eyes. But POST is a heck of a lot easier than having to manage what you're storing in the session array. Worth getting on to your hosting company or getting a new hosting company.

  11. If there is any gap between the top level element and the lower ones that appear, then when you try to move the mouse onto the lower level elements, they will vanish. I decided to make the navigation on my site click-thru, so that it stays open once you click on a top level list item and closes when you either click it closed or click anywhere else on the page. It's worth considering. You can of course have a flyout menu that works purely with CSS as a backup in case the user has JavaScript turned off, but those with it on get the click-thru, which is more reliable and easier to use.

  12. A little :) search reveals that 405 is a status associated with trying to use the POST method on a server not configured to support it / configured to not support it. Try using GET and see if that fixes things. If so, you'll need to contact your host about enabling POST.

  13. Well, you need to know HTML and CSS for the layout, a server side language like PHP for interacting with a database system, you'll need to know how to write queries for the database, such as MySQL, and JavaScript for fetching and loading messages without refreshing the page. The basic idea is:When someone clicks to start a conversation, you need to find out how many users are currently not in a conversation, and choose one at random. A temporary table will probably be created by the database program to store the messages back and forward. A JavaScript loop will start checking for new messages by the other user and if it finds one will output it to the page. This is called AJAX. There are further complexities, of course, but that's the very basic idea.

  14. If you mean that you want to output the tags onto the page instead of them being interpreted by the browser as markup, you can use htmlentities() to turn tags into character set equivalents. You can specify which charset you'd like, but standard is ISO-8859-1. You can use htmentities() to transform input before writing it to the database or afterwards.

  • Create New...