Jump to content

Can i email output of a webpage to a user?


CasperCaro

Recommended Posts

Hi there, ths is my very first post to this site so thanks in advance for reading and suggesting. (And apologies if this is not correct forum)

 

I have a website that generates some output ( onto website File A). I want to email this output that's generated

to a users (inputted) email address.

 

I cant quite work out how to get that output into the email. I can cut and paste (into $menu variable in file B) but i

want to have it done automatically.

 

So far i have the following code (and maybe there's an easier way/ better way), but this is what i have so far.

 

in file A, I have the PHP/MySQL generated output and an "email" icon that displays

(

<input type='image' onClick='myPopup()' img src='email1.jpg' alt='' width='100' height='100' vspace='5' border='10' align='left' ALT='Email' value='Email' />

)

 

this redirects to file B (which pops up and asks for the email address to send generated output of file A to) when user clicks email button..

 

It seems from my investigations so far that I somehow have to get it into $menu variable of file B but am unsure how, or if there is

another way (to how i'm trying)? In IE7 under Page dropdown, there's an option to 'Send page by -Mail...' this is what i want mine to do

 

Could someone have a look and see if there's something I could try - thanks very much

 

 

 

 

 

file B =

 

<html>

<head>

<link rel="stylesheet" type="text/css" media="all" href="style.css"/>

<title>  Email menu </title>

</head>

<body>

<h3><p align="center"><u>Email menu & nutritional information</u></p></h3>  <br><br><br>

<?php echo "<br>"; echo "<br>"; echo "<br>"; ?>

<p><font color="orangered" size="+1"><tt><b>*</b></tt></font> 

  indicates a required field</p> 

<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">

<table border="0" cellpadding="0" cellspacing="5"> 

  <tr> 

      <td align="right"> 

          <p>Email </p> 

      </td> 

      <td> 

          <input name="email" type="text" maxlength="50" size="40" /> 

          <font color="orangered" size="+1"><tt><b>*</b></tt></font> 

      </td> 

  </tr> 

  <tr> 

      <td align="right" colspan="2"> 

          <hr noshade="noshade" />

  <input type="reset" value="Reset Form" />

    <input type="submit" name="submitok" value="EMAIL menu" onClick="javascript:window.close();"/>

      </td> 

  </tr> 

</table> 

<?php

 

$menu="if i cut and paste file A content, it does send but i want automated";

 

if (isset($_POST['submitok'])){

  $message = "Your menu and the nutritional information for that menu below   

       

        $menu;

 

Kind regards,

"; 

 

mail($_POST['email'],"Your menu",$message);

  Header("Location: print_menu_restrict.php");

}

?>

</body>

</html>

I thought this might be tricky - and it's proving to be!

 

I'll ask a related question, but slightly different. I fund the following code

 

<script language="javascript">

function mailpage()

{

  mail_str = "mailto:?subject= Doc JavaScript: " + document.title;

  mail_str += "&body= I recommend Doc JavaScript's (docjavascript.com) tip -- " + document.title;

  mail_str += ". You should check this out at, " + location.href;

  location.href = mail_str;

}

</script>

Somewhere on the page you need to provide a link that calls the above function, like this:

 

<A HREF = "javascript:mailpage()">E-mail This Page</A> E-mail This Page

 

and it would be fine except that my website requires a login. If the user stays logged in then the page from above code is fine and it shows what i want but then it

changes when the user logs out. So my question is - not being familiar too much with javascript is there a code like  " + location.href;

that would give a static page (this one changes as i mention above)  ??  thanks

Never mind - i looked on Javascript forum and can't send emails via JS and what's being sent is a link to page, not the page itself, so it will change. So original question/post is pertinent one. How to automatically get $menu filled in(on Form B)  from form A. If any one has suggestion, much appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.