Jump to content

Archived

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

lounger

Re: send page to friends help please

Recommended Posts

this will show the user profile and a img to the users email account.

copy and past to test

test_result.php

[code]

<?php session_start();

if($_POST['submit']){


$to=$email;

$subject = 'A profile sent to you from a friend';

$message="<html>
<title>members profile</title>
<body>
<h1> members profile for $name</h1>
<br>
<br>
<b>username</b>
<br>
$name
<br>
<b>age</b>
<br>
$age
<br>
<b>members location</b>
<br>
$location
<br>
<b>members description</b>
<br>
$description
<br>
<br>
$name likes this logo
<br>
<img src='http://www.google.co.uk/intl/en_ALL/images/images_hp.gif'></img>
</html>
</body>
";



$headers = "From: Do not email back\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";mail($to, $subject, $message, $headers);

echo "profile sent to $email";
}
?>

sending a profile to your friend <?php echo $name ?>

<form method="POST" action="">
<br>
please enter friends email address
<br>
<input type="text" name="email">
<br>
<input type="submit" name="submit" value="send this profile">
<br>
</form>

[/code]


test.php

[code]

<?php session_start();

$name="redarrow";
$age="32";
$location="london";
$description="redarrow loves php";

$name=$_SESSION['name']=$name;
$age=$_SESSION['age']=$age;
$location=$_SESSION['location']=$location;
$description=$_SESSION['description']=$description;

?>

<html>
<title>members profile</title>
<body>
<h1> members profile for <?php echo $name?></h1>
<br>
<br>
<b>username</b>
<br>
<?php echo $name?>
<br>
<b>age</b>
<br>
<?php echo $age ?>
<br>
<b>members location</b>
<br>
<?php echo $location?>
<br>
<b>members description</b>
<br>
<?php echo $description?>
<br>
<br>
<br>
<a href="test_result.php">email profile to friend</a>
</html>
</body>

[/code]

Share this post


Link to post
Share on other sites
hi redarrow i tried the code but it leaves my gallery page blank? is there not a way i can just adapt the send page to friends script that i have posted in pastebin as i already have this script on my website and it works great except for sendind the wrong url?

Share this post


Link to post
Share on other sites
you have to save the two pages i posted as seprate pages test.php and test_result.php in the root directory and dont alter them.

point you browser to the test.php then your see a profile with a link to send the profile to a email address you then goto test_result.php and then you emter your email address and then you get the profile what is set in the meesage varable on the mail code your also see an image that is from google try it works grate.

when you got it going add it to your existing code and change what needs to be changed that easy.

your existing code has got lot off flaws in it so you need to redesign it and this code that i have provided should do the trick trust me ok.

Share this post


Link to post
Share on other sites
hi redarrow i have this on my server and your right it works i get the google image but i need it to send a pic from my gallery section which has around 300 images in it how do i get it to do this for each image?

Share this post


Link to post
Share on other sites
i think your idear is inpossable as your email account will get ban 1 pic ok but 300 bad idear sorry.

the best solution is to provide a link in the email to view the pics ok.

Share this post


Link to post
Share on other sites
i dont think you understand what i am saying i only need the script to send 1 pic at a time, but will it be able to send each pic on every page by picking up the image url or do i need to manually enter the image url myself for each pic?

Share this post


Link to post
Share on other sites
somethink like this ok.

the id will be the members id and in the image database each image should have that users id to get that image ok also in the query limit it to 1 incase there more then one so the email only gets one ok..

you need to setup the database entrys and the select statement and then try to display a users image with this code below before we go any futher.

when you got that going then we can add it to the code i posted but not untill then ok.
[code]
<?php session_start();

// we need session start at the top of page to get the users id

// need database connection information

$db=mysql_connect("localhost" "xxxxxx","xxxxxx");

// need the correct database to use
mysql_select_db("xxxxx",$db);

// need to select the database that holds the images
$query="select * from xxxxxx where id='$id' limit 1";

// query the query
$result=mysql_query($query);

// a while loop to get the images from the database while loop set to $image
while($image=mysql_fetch_assoc($result)){

// set image to the while loop the xxxx is the name of the database field that the select statement resides
$image=$image['xxxx'];

//make a friendly link to get the images
$image_link="<img src='myurl/folder/$image'></img>";

//echo the image out but only one
echo $image_link
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.