Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    4
    Member #
    13053
    hello,

    i just started to make web pages, and i tried to make a script so i could send e-mails. i found a site that showed me how, but when i put it in the page wont stop refreshing. here is the script:

    <?php



    $subject = 'Results from Contact form';

    $emailadd = 'mail@rdsnetworks.net';

    $url = 'http://www.rdsnetworks.net/confirmation.html';


    $req = '0';


    $text = "Results from form:\n\n";
    $space = ' ';
    $line = '
    ';
    foreach ($_POST as $key => $value)
    {
    if ($req == '1')
    {
    if ($value == '')
    {echo "$key is empty";die;}
    }
    $j = strlen($key);
    if ($j >= 20)
    {echo "Name of form element $key cannot be longer than 20 characters";die;}
    $j = 20 - $j;
    for ($i = 1; $i <= $j; $i++)
    {$space .= ' ';}
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = ' ';
    }
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>

    is there something wrong with the script or am i doing something?

    p.s. i did change the e-mail/ site redirect

    thanx in advance

  2.  

  3. #2
    Senior Member mossoi's Avatar
    Join Date
    Apr 2003
    Location
    Englandshire, United Kingdomsville y'all!
    Posts
    1,111
    Member #
    1206
    Liked
    1 times
    This line:
    Code:
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    Is telling the browser to load the page you've set for $url at the top of the code. If that's that's the page which contains the code you've posted above then it's just gonna keep refreshing (while repeatedly sending out the same email).

    You can either remove that line altogether or change it to redirect to a seperate confirmation page.

  4. #3
    Junior Member
    Join Date
    Apr 2006
    Posts
    4
    Member #
    13053
    i tried to do two things to the code: delete both lines involving the redirect, which cancles out the e-mail part and 2. deleteing only the second e-mail line, causing a script error. what do i do now?

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Do not delete both lines, either delete the refresh line, or edit the value of $url to a different page.

    Or, instead of doing the refresh, do something like:
    PHP Code:
    if(mail($emailadd$subject$text'From: '.$emailadd.''))
       {
          echo 
    "Email sent!";
       } 
    Your script above with the modification,
    PHP Code:
    <?php

    $subject 
    'Results from Contact form';
    $emailadd 'mail@rdsnetworks.net';
    $url 'http://www.rdsnetworks.net/confirmation.html'// dont need this anymore
    $req '0'// numbers dont need quotes

    $text "Results from form:\n\n";
    $space ' ';
    $line '
    '
    ;
    foreach (
    $_POST as $key => $value)
    {
    if (
    $req == '1')
    {
    if (
    $value == '')
    {echo 
    "$key is empty";die;}
    }
    $j strlen($key);
    if (
    $j >= 20)
    {echo 
    "Name of form element $key cannot be longer than 20 characters";die;}
    $j 20 $j;
    for (
    $i 1$i <= $j$i++)
    {
    $space .= ' ';}
    $value str_replace('\n'"$line"$value);
    $conc "{$key}:$space{$value}$line";
    $text .= $conc;
    $space ' ';
    }
    if(
    mail($emailadd$subject$text'From: '.$emailadd.''))
       {
          echo 
    "Email sent!";
       }

    ?>
    Good luck.

  6. #5
    Junior Member
    Join Date
    Apr 2006
    Posts
    4
    Member #
    13053
    i tried to put your code in, but now instead of refreshing it just sends a bunch of blank e-mails to me and only half of the code works... the other half goes in plain text under submit and is not in different colors when in code view

  7. #6
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Could we see a page with the code on?


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com