Problem submitting previously working form on new server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • a c s

    Problem submitting previously working form on new server

    Hello, I'm a php newbie and have been using the following php code fine
    (until now) to submit a form and create an email message. I recently
    moved the site from a local server to an ISP's server and now, whenever
    I attempt to submit the form, the entries I made are cleared and no
    e-mail is sent.

    I have no idea what the problem is - can anyone help?


    ------------begin extracted php---------------
    <?php
    if ($_SERVER['REQUEST_METHOD '] != 'POST'){
    $me = $_SERVER['PHP_SELF'];
    print <<<TOEND

    <form name="form1" method="post" action="$me">

    Name: <input type="text" name="Name">
    Subject: <input type="text" name="Subject"> </td>
    Message: <textarea name="MsgBody"> </textarea></td>
    <input type="submit" name="Submit" value="Send"></td>

    </form>



    TOEND;

    } else {
    error_reporting (0);
    $recipient = 'alan@innovez.c o.uk';
    $subject = stripslashes($_ POST['Subject']);
    $from = stripslashes($_ POST['Name']);
    $msg = "Message from: $from\n\n".stri pslashes($_POST['MsgBody']);
    if (mail($recipien t, $subject, $msg))
    echo nl2br("<b>Messa ge Sent:</b>
    To: $recipient
    Subject: $subject
    Message:
    $msg");
    else
    echo "Message failed to send";
    }
    ?>
    ------------end extracted php---------------


  • Pedro Graca

    #2
    Re: Problem submitting previously working form on new server

    ["Followup-To:" header set to comp.lang.php.]
    a c s wrote:[color=blue]
    > Hello, I'm a php newbie and have been using the following php code fine
    > (until now) to submit a form and create an email message. I recently
    > moved the site from a local server to an ISP's server and now, whenever
    > I attempt to submit the form, the entries I made are cleared and no
    > e-mail is sent.
    >
    > I have no idea what the problem is - can anyone help?[/color]

    (... snip ...)
    [color=blue]
    > } else {
    > error_reporting (0);[/color]

    Try
    error_reporting (E_ALL);

    instead.


    Then correct all Notices, Warnings and Errors, and repost if it still
    doesn't work.

    --
    USENET would be a better place if everybody read: | to email me: use |
    http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
    http://www.netmeister.org/news/learn2quote2.html | header, textonly |
    http://www.expita.com/nomime.html | no attachments. |

    Comment

    • a c s

      #3
      Re: Problem submitting previously working form on new server

      Hi Pedro,

      I have changed the error_reporting function to E_ALL but there is no
      change in behavior: the form just resets itself.

      Any other ideas? With thanks, Alan.


      Pedro Graca wrote:[color=blue]
      > ["Followup-To:" header set to comp.lang.php.]
      > a c s wrote:
      >[color=green]
      >>Hello, I'm a php newbie and have been using the following php code fine
      >>(until now) to submit a form and create an email message. I recently
      >>moved the site from a local server to an ISP's server and now, whenever
      >>I attempt to submit the form, the entries I made are cleared and no
      >>e-mail is sent.
      >>
      >>I have no idea what the problem is - can anyone help?[/color]
      >
      >
      > (... snip ...)
      >
      >[color=green]
      >> } else {
      >> error_reporting (0);[/color]
      >
      >
      > Try
      > error_reporting (E_ALL);
      >
      > instead.
      >
      >
      > Then correct all Notices, Warnings and Errors, and repost if it still
      > doesn't work.
      >[/color]

      Comment

      • Pedro Graca

        #4
        Re: Problem submitting previously working form on new server

        a c s top-posted:[color=blue]
        > I have changed the error_reporting function to E_ALL but there is no
        > change in behavior: the form just resets itself.
        >
        > Any other ideas? With thanks, Alan.[/color]

        Hmmm ... It worked perfectly here.

        What PHP version is running on your server?

        <?php echo phpversion(); ?>


        $_SERVER, $_POST, ... are available from PHP 4.1.0 onwards.
        If you use an earlier version substitute those superglobal arrays with
        $HTTP_SERVER_VA RS, $HTTP_POST_VARS , ...

        http://www..php.net/manual/en/reserved.variables.php


        --
        USENET would be a better place if everybody read: | to email me: use |
        http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
        http://www.netmeister.org/news/learn2quote2.html | header, textonly |
        http://www.expita.com/nomime.html | no attachments. |

        Comment

        • a c s

          #5
          Re: Problem submitting previously working form on new server

          Sir, you are a genius - the version of PHP on the server was 4.0.6.

          The workaround sorted the problem nicely, and it'll be added to my
          troubleshooting list for the future.

          Thanks again, Alan.

          Pedro Graca wrote:
          [color=blue]
          > a c s top-posted:
          >[color=green]
          >>I have changed the error_reporting function to E_ALL but there is no
          >>change in behavior: the form just resets itself.
          >>
          >>Any other ideas? With thanks, Alan.[/color]
          >
          >
          > Hmmm ... It worked perfectly here.
          >
          > What PHP version is running on your server?
          >
          > <?php echo phpversion(); ?>
          >
          >
          > $_SERVER, $_POST, ... are available from PHP 4.1.0 onwards.
          > If you use an earlier version substitute those superglobal arrays with
          > $HTTP_SERVER_VA RS, $HTTP_POST_VARS , ...
          >
          > http://www..php.net/manual/en/reserved.variables.php
          >
          >[/color]

          Comment

          • a c s

            #6
            Re: Problem submitting previously working form on new server

            Hi Pedro,

            Have you any idea why (it seems only in PHP versions less than 4.1.0)
            the attachment received is an empty "attachment.txt " file instead of the
            actual file I attached?

            Many thanks in advance, Alan.

            Pedro Graca wrote:
            [color=blue]
            > a c s top-posted:
            >[color=green]
            >>I have changed the error_reporting function to E_ALL but there is no
            >>change in behavior: the form just resets itself.
            >>
            >>Any other ideas? With thanks, Alan.[/color]
            >
            >
            > Hmmm ... It worked perfectly here.
            >
            > What PHP version is running on your server?
            >
            > <?php echo phpversion(); ?>
            >
            >
            > $_SERVER, $_POST, ... are available from PHP 4.1.0 onwards.
            > If you use an earlier version substitute those superglobal arrays with
            > $HTTP_SERVER_VA RS, $HTTP_POST_VARS , ...
            >
            > http://www..php.net/manual/en/reserved.variables.php
            >
            >[/color]

            Comment

            • Pedro Graca

              #7
              Re: Problem submitting previously working form on new server

              a c s top-posted:[color=blue]
              > Hi Pedro,[/color]

              To mail me use my address and follow the indications in the signature.
              If you ask me something by mail I probably will tell you to ask in the
              newsgroup instead :)
              [color=blue]
              > Have you any idea why (it seems only in PHP versions less than 4.1.0)
              > the attachment[/color]

              Attachment? ?!?!?!? What do you mean?
              Something in MIME e-mail, perhaps?
              [color=blue]
              > received[/color]

              received? ?!?!?!? What do you mean?
              Received by what?
              A mail client?
              A HTTP server?
              A IRC client?

              And, if it was received, it must have been sent. Sent by what?
              A PHP script?
              A mail client?
              An FTP-to-Mail server?
              [color=blue]
              > is an empty "attachment.txt " file instead of the
              > actual file I attached?[/color]

              Where could the attachment be lost?
              One of several places:
              a) before being sent
              b) at the moment of sending
              c) between being sent and received
              d) at the moment of receiving
              e) after being received

              You say it's at c); I guess it's at b) -- or even at a)
              Verify your sending script.



              PS. What is the relation between the failed "received attachment"
              and switching a form to a different server (the subject of this
              post)?


              --
              USENET would be a better place if everybody read: | to email me: use |
              http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
              http://www.netmeister.org/news/learn2quote2.html | header, textonly |
              http://www.expita.com/nomime.html | no attachments. |

              Comment

              • a c s

                #8
                Re: Problem submitting previously working form on new server

                Pedro. My apologies. My script had a missing semi-colon.

                Thanks again, Alan.

                Pedro Graca wrote:[color=blue]
                > a c s top-posted:
                >[color=green]
                >>Hi Pedro,[/color]
                >
                >
                > To mail me use my address and follow the indications in the signature.
                > If you ask me something by mail I probably will tell you to ask in the
                > newsgroup instead :)
                >
                >[color=green]
                >>Have you any idea why (it seems only in PHP versions less than 4.1.0)
                >>the attachment[/color]
                >
                >
                > Attachment? ?!?!?!? What do you mean?
                > Something in MIME e-mail, perhaps?
                >
                >[color=green]
                >>received[/color]
                >
                >
                > received? ?!?!?!? What do you mean?
                > Received by what?
                > A mail client?
                > A HTTP server?
                > A IRC client?
                >
                > And, if it was received, it must have been sent. Sent by what?
                > A PHP script?
                > A mail client?
                > An FTP-to-Mail server?
                >
                >[color=green]
                >>is an empty "attachment.txt " file instead of the
                >>actual file I attached?[/color]
                >
                >
                > Where could the attachment be lost?
                > One of several places:
                > a) before being sent
                > b) at the moment of sending
                > c) between being sent and received
                > d) at the moment of receiving
                > e) after being received
                >
                > You say it's at c); I guess it's at b) -- or even at a)
                > Verify your sending script.
                >
                >
                >
                > PS. What is the relation between the failed "received attachment"
                > and switching a form to a different server (the subject of this
                > post)?
                >
                >[/color]

                Comment

                Working...