Page 1 of 1

how to make the contents of a php page come to email address

Posted: Tue Jan 27, 2009 4:55 pm
by Willpower
Hi guys.
I have this page
http://www.thechallenge.net.au/superredemption.php
I want all the contents of the tex fields to come to me as an email.
I would normally action the form to use this page
http://www.thechallenge.net.au/Redemptionform.txt
But as my form now has <?php echo $editFormAction; ?> in the action firld due to an insert record behaviour I can no longer action it to my usual email form.
Can anyone suggest a solution to this?
Thanks in advance.

Re: how to make the contents of a php page come to email address

Posted: Tue Jan 27, 2009 5:17 pm
by pickle
Your kind of out of luck. The form data is only sent to where the action attribute tells it.

Re: how to make the contents of a php page come to email address

Posted: Tue Jan 27, 2009 8:06 pm
by Schneider707
i know this might be a little crazy but you could write it to a text file, then reopen it and fire the contents off to your email then unlink the text file...

Re: how to make the contents of a php page come to email address

Posted: Wed Jan 28, 2009 1:39 am
by jothirajan
Hi ..please explain me that you content is a HTML page...

I will help...it's easy to get this problem down...

Thanks
JOE....

Re: how to make the contents of a php page come to email address

Posted: Wed Jan 28, 2009 2:42 am
by Willpower
Hi jothirajan
Basically
I want the contents of the form in the page to come to me as an email but without losing the insert record behaviour that the form has attached to it already.

Re: how to make the contents of a php page come to email address

Posted: Wed Jan 28, 2009 3:00 am
by jothirajan
Try this one:

Use your form in the body of the HTML tag and send the mail.

What ever it may a HTML page or the records from database table....

Thanks
JOE..
Get me if you want more....



<?php
$SelQuery1 = "SELECT * FROM ".TABLE_NAME."";





$message='<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>mywordrobe.com</title>
</head>

<body>
//// assign the value from the database
//// or you can add the content
//// but path should be in full version
</body>
</html>';
$subject="YOUR SUBJECT";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From:".$from."";
@mail($to,$subject,$message,$headers) ;
?>

Re: how to make the contents of a php page come to email address

Posted: Wed Jan 28, 2009 6:32 pm
by Willpower
Thanks for the reply jothirajan but I have no idea what you are talking about.
Are you able to paste the amended code in full for me to try on my server?

Re: how to make the contents of a php page come to email address

Posted: Wed Jan 28, 2009 6:44 pm
by nor0101
You don't have to choose between sending the data in an email or inserting it into a database. You can do both! Your first step is going to be finding out the value of $editFormAction. Once you know what script to edit, find where in the code the database query takes place.

The data should still be available for you to use. For example, if you wanted to generate something simple that gives the form field name followed by the input value for each element:

Code: Select all

 
$fieldNames = array_keys($_REQUEST);
$fieldVals = array_values($_REQUEST);
 
$numFields = count($fieldNames);
 
$msg_body = "";
 
for ($i=0; $i<$numFields; $i++) {
    $msg_body .= $fieldNames[$i]." = ".$fieldVals[$i]."\n\n";
}
 
Then look up the mail() function in the documentation to send $msg_body wherever it needs to go.

Re: how to make the contents of a php page come to email address

Posted: Fri Jan 30, 2009 5:54 pm
by Willpower
Thanks you so much for your reply.
As I am learning php as I go I am still haveing trouble understanding where to put that snippet of code. I tried a few ways with no success.
Are you able to insert it in this code for me?

Code: Select all

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="superredemptionincorrect.php";
  $loginUsername = $_POST['YourPayPalreceiptnumber'];
  $LoginRS__query = sprintf("SELECT numbers FROM pay_pal_numbers WHERE numbers=%s", GetSQLValueString($loginUsername, "text"));
  mysql_select_db($database_thechall_thechallenge, $thechall_thechallenge);
  $LoginRS=mysql_query($LoginRS__query, $thechall_thechallenge) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
 
  //if there is a row in the database, the username was found - can not add the requested username
  if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
  }
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO pay_pal_numbers (numbers) VALUES (%s)",
                       GetSQLValueString($_POST['YourPayPalreceiptnumber'], "text"));
 
  mysql_select_db($database_thechall_thechallenge, $thechall_thechallenge);
  $Result1 = mysql_query($insertSQL, $thechall_thechallenge) or die(mysql_error());
 
  $insertGoTo = "Redemptionform.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="shortcut icon" href="images/icon.ico" />
<link rel="stylesheet" href="lightbox_assets/css/lightbox.css" type="text/css" media="screen" />
<script src="lightbox_assets/js/prototype.js" type="text/javascript"></script>
<script src="lightbox_assets/js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="lightbox_assets/js/lightbox.js" type="text/javascript"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>The Challenge / Redemption</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="layout.css" rel="stylesheet" type="text/css" />
<script src="maxheight.js" type="text/javascript"></script>
<style type="text/css">
<!--
.style2 {
    color: #FF0000;
    font-weight: bold;
    font-family: Tahoma;
    font-size: medium;
}
.style9 {
    font-size: medium;
    color: #295628;
    font-family: Tahoma;
}
.style11 {font-size: x-large}
.style12 {font-size: xx-large}
.style14 {color: #3A5E35}
.style18 {color: #295628}
.style4 {font-family: Tahoma;
    font-size: xx-large;
}
.style5 {   font-family: Tahoma;
    font-size: xx-large;
    color: #295825;
}
a:link {
    color: #295628;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #295628;
}
a:hover {
    text-decoration: underline;
    color: #CCCC00;
}
a:active {
    text-decoration: none;
    color: #CCCC00;
}
.style20 {color: #FF0000}
.style21 {color: #FF0000; font-weight: bold; font-family: Tahoma; font-size: medium; }
-->
</style>
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>
 
<body id="index_4" onload="new ElementMaxHeight();initLightbox()">
    <div id="header_tall">
        <div id="main">
            <!--header -->
            <div id="header">
                <div class="h_logo">
                  <div class="clear"></div>
                </div>
                <div id="menu">
                    <div class="rightbg">
                        <div class="leftbg">
                          <div class="padding">
                            <ul>
                              <li><a href="index.html">Home</a></li>
                              <li><a href="Challenges.html">Challenges</a></li>
                              <li><a href="Blog/index.php">Blog</a></li>
                              <li><a href="redemption.html">Redemption</a></li>
                              <li><a href="sms.html">Challenge sms</a></li>
                              <li class="last"><a href="subscribe.php">Join up</a></li>
                            </ul>
                            <br class="clear" />
                          </div>
                        </div>
                    </div>
                </div>
                <div class="content"><br />
                <br />
                <div class="clear"></div>
                </div>
          </div>
            <!--header end-->
            <div id="middle">
                <div class="indent">
                  <div class="column1">
                    <div class="padding1">
                      <div class="bot_line">
                        <div class="content">
                          <p align="center" class="style21">Welcome to your Super Redemption.</p>
                          <p align="center" class="style21">&nbsp;</p>
                          <p align="center" class="style9">This is where you redeem your prize for completing a </p>
                          <p align="center" class="style9"><a href="proffesional.html" target="_blank" class="style20">"Super</a><a href="proffesional.html"> Professional"</a> version of your chosen challenges.</p>
                          <p align="center" class="style9">&nbsp;</p>
                          <p align="center" class="style9">Please enter you details below to redeem your prizes.</p>
                          <p align="center" class="style9">&nbsp;</p>
                          <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1" onsubmit="MM_validateForm('ChallengeNumber','','R','YourPayPalreceiptnumber','','R','prize','','R','prize2','','R','prize3','','R','prize4','','R','mailing address','','R','name','','R','phone number','','R');return document.MM_returnValue">
                            <label><span class="style2">1.</span> Enter your 4 challenge numbers
                            <br />
                            <input type="text" name="ChallengeNumber" id="ChallengeNumber" />
                            <br />
                            <br />
                            <br />
                            <span class="style2">2.</span> Enter your Pay Pal receipt number </label>
                            <label>
                            <input type="text" name="YourPayPalreceiptnumber" id="YourPayPalreceiptnumber" />
                            <br />
                            <br />
                            <br />
                            </label>
                            <p><span class="style2">3.</span> Choose your  charity
                              <select name="select" id="select">
                                <option>A $20 Contribution to Canteen</option>
                                <option>A $20 Contribution to ACF</option>
                                <option>A $20 Contribution to the RSPCA</option>
                              </select>
                            </p>
                            <p>&nbsp;</p>
                            <p>&nbsp;</p>
                            <p><span class="style2">4.</span> Choose your prize from below </p>
                            <p>&nbsp;</p>
                            <table width="346" border="0" align="center" class="style9">
                              <tr>
                                <th width="78" scope="col"><a href="images/fs1-sml.jpg" title="Polar fs 1 Heart rate monitor. Retail $110" rel="lightbox"><img src="/images/fs1-smlthumb.jpg" alt="Polar Fs1 Heart rate monitor" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                                <th width="78" scope="col"><a href="images/thorloMiniCrew.jpg" title="2 pairs of Thorlo running socks from Will Power Personal Training" rel="lightbox"><img src="/images/thorloMiniCrewThumb.jpg" alt="2 pairs of Thorlo coolmax running socks" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a><a href="images/thorloMiniCrew.jpg" title="Thorlo Coolmax running socks from Will Power Personal Training." rel="lightbox"></a></th>
                                <th width="78" scope="col"><a href="images/skins-sport-half-black.jpg" title="Skins half tight compression shorts" rel="lightbox"><img src="/images/skins-sport-half-blackThumb.jpg" alt="1 pair of Skins Half tights compression shorts" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a><a href="images/skins-sport-half-black.jpg" title="Skins Half Tight Compression pants" rel="lightbox"></a></th>
                                <th width="78" scope="col"><a href="images/SwissBall.jpg" title="1 x 65 cm Mediball CLASSIC swiss ball" rel="lightbox"><img src="/images/SwissBallThumb.jpg" alt="1 x 65 cm Mediball CLASSIC swiss ball" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                                <th width="12" scope="col"><a href="images/sissel-circle.jpg" title="Sissel Pilates Magic Circle inc. FREE exercise poster" rel="lightbox"><img src="/images/sissel-circlethumb.jpg" alt="1 x 65 cm Mediball CLASSIC swiss ball" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                              </tr>
                              <tr>
                                <th scope="col"><a href="images/YogaMatt.jpg" title="Comffit Exercise Mat (180 x 60 x 1.5)" rel="lightbox"><img src="/images/YogaMattThumb.jpg" alt="Comffit Exercise Mat (180 x 60 x 1.5)" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                                <th scope="col"><a href="images/pedometer_sml.jpg" title="2 x Yamax 10,000 Step Digi Pedometer including FREE safety strap, guide & log book" rel="lightbox"><img src="/images/pedometer_smlThumb.jpg" alt="Yamax 10,000 Step Digi Pedometer including FREE safety strap, guide & log book" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                                <th scope="col"><a href="images/SYSCVoucher.jpg" title="A discounted Gym Membership at the South Yarra Sports Centre" rel="lightbox"><img src="/images/GymMembershipThumb.jpg" alt="A discounted Gym Membership at the South Yarra Sports Centre" width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                                <th scope="col"><a href="images/TrainingSessionWithWillpower.jpg" title="A 1 hour training session with Will Power P.T. at the Melbourne Botanical Gardens or Albert Park Lake." rel="lightbox"><img src="/images/TrainingSessionWithWillpowerThumb.jpg" alt="1 Hour training session with Will Power P.T." width="80"
height="80" onclick="document.form1.prize.value=this.alt" /></a></th>
                                <th scope="col">&nbsp;</th>
                              </tr>
                            </table>
                            <p align="center">&nbsp;</p>
                            <p align="center">
                              <label></label>
                              <span class="style20">Click a prize image to be inserted here</span>
                              <input name="prize" type="text" id="prize" size="40" readonly="readonly" />
                              <br />
                              <br />
                            </p>
                            <p>
                              <label></label>
                            </p>
                            <p><span class="style2">5.</span> Enter your mailing address including postcode
                              <label>
                                <input type="text" name="mailing address" id="mailing address" />
                              </label>
                            </p>
                            <p>&nbsp;</p>
                            <p><span class="style2">6.</span> Enter your name
                              <label>
                                <input type="text" name="name" id="name" />
                                </label>
                            </p>
                            <p>&nbsp;</p>
                            <p><span class="style2">7.</span> Enter your phone number in country and area code</p>
                            <p>
                              <label>
                              <input type="text" name="phone number" id="phone number" />
                              </label>
                            </p>
                            <p>&nbsp;</p>
                            <p><span class="style2">8.</span> Enter any additional notes like size etc.</p>
                            <p>
                              <label>
                              <input name="Additional notes" type="text" id="Additional notes" value="" size="40" />
                              </label>
                            </p>
                            <p>&nbsp;</p>
                            <p>
                              <label>
                              <input type="submit" name="button" id="button" value="Submit" />
                              </label>
                              <label>
                              <input type="reset" name="button2" id="button2" value="Reset" />
                              </label>
                            </p>
                            
                            <input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
&nbsp;</p>
                                                    <p>
                                                      <label></label>
                                                    </p>
                                                    </form>
                          <p align="center" class="style9">&nbsp;</p>
                        </div>
                      </div>
                    </div>
                    <div class="padding2">
                      <div class="style9">
                        <p>&nbsp;</p>
                        <p>
<br />
                        </p>
                      <div class="clear" /></div>
                    </div>
                    </div>
                  </div>
                </div>
                    <div class="column2">
                      <div class="border">
                        <div class="btall">
                          <div class="ltall">
                            <div class="rtall">
                              <div class="tleft">
                                <div class="tright">
                                  <div class="bleft">
                                    <div class="bright">
                                      <div class="ind">
                                        <div class="h_text">
                                          <p><a href="Challenges.html"><img src="images/ChallengeStep1.jpg" alt="" width="230" height="43" /></a></p>
                                          <p><a href="Blog/index.php"><img src="images/ChallengeStep2.jpg" alt="" width="230" height="43" /></a></p>
                                          <p><a href="redemption.html"><img src="images/ChallengeStep3.jpg" alt="" width="230" height="43" /></a></p>
                                          <p><span class="style4"><span class="style12"><img src="images/Spacer.jpg" alt="" width="229" height="23" /></span></span></p>
                                        </div>
                                        <div class="style5">
                                          <ul class="style11" >
                                            <li class="style12">
                                              <p><a href="http://www.thechallenge.net.au/Blog" target="_blank" class="style14">Post on the blog here</a></p>
                                            </li>
                                            <li class="style12">
                                              <p><a href="tunes.html?feed=rss2" target="_blank" class="style14">Top 10 motivating Itunes</a></p>
                                            </li>
                                            <li class="style12">
                                              <p><span class="style18"><a href="http://www.thechallenge.net.au/Blog/?feed=rss2" target="_blank" class="style14">Rss feed</a></span></p>
                                            </li>
                                          </ul>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="margin">
                        <div class="border">
                          <div class="btall">
                            <div class="ltall">
                              <div class="rtall">
                                <div class="tleft">
                                  <div class="tright">
                                    <div class="bleft">
                                      <div class="bright">
                                        <div class="ind">
                                          <form action="" class="style2" id="searchbox_000711922427475317324:qrs_qrg_o7y" onsubmit="return false;">
                                            <div>
                                              <input type="text" name="q" size="25"/>
                                              <input type="submit" value="Search"/>
                                            </div>
                                          </form>
                                          <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_000711922427475317324%3Aqrs_qrg_o7y&lang=en"></script>
                                          <div id="results_000711922427475317324:qrs_qrg_o7y" style="display:none">
                                            <div class="cse-closeResults"> <a>&times; Close</a> </div>
                                            <div class="cse-resultsContainer"></div>
                                          </div>
                                          <p>
                                            <style type="text/css">
@import url(http://www.google.com/cse/api/overlay.css);
                                          </style>
                                          </p>
                                          <p>&nbsp; </p>
                                          <p>
                                            <script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=ABQIAAAA1uC1NaKddpJF4LU1g1LbDBSSr4BkDe5lrHX3JuMtfjpA19Y7URQk64feEjaszGMN2Am2ej-AyO0XYg&hl=en" type="text/javascript"></script>
                                            <script src="http://www.google.com/cse/api/overlay.js" type="text/javascript"></script>
                                            <script type="text/javascript">
function OnLoad() {
  new CSEOverlay("000711922427475317324:qrs_qrg_o7y",
                 document.getElementById("searchbox_000711922427475317324:qrs_qrg_o7y"),
                 document.getElementById("results_000711922427475317324:qrs_qrg_o7y"));
}
GSearch.setOnLoadCallback(OnLoad);
                                            </script>
                                          <a href="http://www.canteen.org.au" target="_blank"><img src="images/canteen_logo_hp.gif" alt="" width="230" height="121" /></a></p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p><a href="http://www.acfonline.org.au/" target="_blank"><img src="images/ACFlogo.gif" alt="" width="230" height="70" /></a></p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p><a href="http://www.rspca.org.au/" target="_blank"><img src="images/RSPCA.gif" alt="" width="230" height="65" /></a></p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p><a href="http://www.willpower.net.au" target="_blank"><img src="images/WillPowerLogo.jpg" alt="" width="230" height="120" /></a></p>
                                          <p>&nbsp;</p>
                                       
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                          <p>&nbsp;</p>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
          </div>
          <div class="clear"></div>
          </div>
      </div>
            <!--footer -->
            <div id="footer">
                <div class="indent">
                    <div align="center">&copy; "The Challenge" 2008 Website by <a href="http://www.rounddesign.net" target="_blank">Round Design</a></div>
                </div>
</div>
            <!--footer end-->
</div>
</body>
</html>

Re: how to make the contents of a php page come to email address

Posted: Fri Jan 30, 2009 5:59 pm
by Benjamin
Please edit your post using the proper [ code = php ] tags.