Jump to content

mads

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Posts posted by mads

  1. That didn't help :(

     

    I added session_save_path("mysessions") right before session_start() in header.php. Afterwards, I can see the session files being created in the "mysessions" directory on the webserver, but the session variable still doesn't exist when I need it in go.php

     

    Any other ideas on what might be going wrong?

     

    Thanks again,

    Mads

  2. I have no idea why, but sometimes my session variable disappears. After having stared at it for two days, I guess it's time to cry for help...

     

    This is how I set the variable and later try to use it again:

     

    1) I'm creating a session in header.php (a file that is loaded everytime a webpage is displayed):

    session_start();

    ...

    $_SESSION['displaymode'] = "abe";

     

    2) I'm using the variable in go.php (which does not load header.php when it is displayed):

    session_start();

    ...

    if(isset($_SESSION['displaymode']))

    {

        $displaymode = $_SESSION['displaymode'];

    }

     

    Can anyone see why my session variable disappears? isset() returns false approx. 50% of the time and I have absolutely no idea why :(

     

    Thanks a lot,

    Mads

     

     

     

  3. It also doesn't work on my machine at home, but I have discovered something: The script works perfectly if I put it in a seperate file and upload it.

    Both Daniel0's (http://www.horseornot.com/abe1.php) and my script (http://www.horseornot.com/abe2.php) work if I put them in seperate files (although Daniel0's script look far better when it's placed in a seperate file...).

    Guess the conclusion is that Wordpress affect how my textarea behaves, so I will move to the wordpress forum and annoy people there  :P
    http://wordpress.org/support/topic/90903?replies=1

    Thank you for all your help.
  4. Yes, it is running your script right now (http://www.horseornot.com/tell-a-friend/)

    I noticed that you haven't got any line breaks in your screenshots. Does it still work if you add some line breaks?

    Maybe it's worth mentioning that my script runs inside a page created by Wordpress.
  5. Still no luck - sad to report that the long piece of code doesn't improve things.

    I have moved some of the things outside the textarea. It looks like "html_entity_decode($message_text);" do what it is supposed to do, so the problem is caused by the textarea.

  6. Thank you for your reply.

    Works great for the text inputs, but the textarea behaves a little bit crazy. It shows the HTML tags when the page reloads...?

    Check it out here:
    http://www.horseornot.com/tell-a-friend/

    (Just forget to fill out one of the e-mail address fields in order to see the effect)
  7. Aloha,

    I have created a simple tell a friend form. If the user click send without filling out all of the required fields, I show an error message and the form once more. My problem is that the contents of the form get cleared when I reload the form :(

    I would of course like to keep the contents, so the user doesn't get annoyed and leave my website without telling their friends. How do I keep the contents?

    Here is the complete (sigh...) code for my form:
    ------------------------------------------------------------------------
    Please fill out this form and click send.

    <?php
    unset($message_sendername);
    unset($message_sender);
    unset($message_recipient);
    unset($message_subject);
    unset($message_text);

      // Get the image text and title
      $message_sendername = $_POST["message_sendername"];
      $message_sender = $_POST["message_sender"];
      $message_recipient = $_POST["message_recipient"];
      $message_subject = $_POST["message_subject"];
      $message_text = $_POST["message_text"];

    // Validation
    if($_POST["action"] == "Send")
    {
    if(empty($message_sendername) == true || empty($message_sender) == true)
    {
    $error["message_sender"] = "Please write your own name or your own e-mail address.";
    }

    if(empty($message_recipient) == true)
    {
    $error["message_recipient"] = "Please write your friend's e-mail address.";
    }

    if(empty($error) == false)
    {
    unset($_POST["action"]);
    }
    }

    if($_POST["action"] == "Send")
    {
    $headers  = "From: \"$message_sendername\"<$message_sender>\n";

    // Send the e-mail
    mail($message_recipient, $message_subject, $message_text, $headers);

    print("<p>Your message has been sent to $message_recipient.<br/><br/><a href='/tell-a-friend'>Send another message</a></p>");
    }
    else
    {
    // Show errors - if any
    if(is_array($error))
    {
    print("Something went wrong:<br/><font color='#FF0000'>");
    while(list($key, $val) = each($error))
    {
    print("$val");
    print("<br>\n");
    }
    print("</font>");
    }
    ?>
    <table>
    <tr><td width="10%"></td><td width="80%">
    <form method="POST" enctype="multipart/form-data" name="tell_a_friend_form" action="<?$_SERVER["PHP_SELF"];?>" >
    <p>Your name:
    <input type="text" name="message_sendername" size="60" maxlength="60"></p>
    <p>Your e-mail address:
    <input type="text" name="message_sender" size="60" maxlength="60"></p>
    <p>Friend's e-mail address:
    <input type="text" name="message_recipient" size="60" maxlength="60"></p>
    <p>E-mail subject:
    <input type="text" name="message_subject" size="60" maxlength="60"></p>
    <p>E-mail text:
    <textarea name="message_text" rows="10" cols="45"></textarea></p>
    <p><input type="submit" value="Send" name="action"></p>
    </form>
    </td><td width="10%"></td>
    </tr>
    </table>
    <?php
    }
    ?>
    ------------------------------------------------------------------------

    Thank you, Mads
×
×
  • 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.