Approve the Cookies
This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies and our Privacy Policy.
OK
Forums  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear
Guest
Forums  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear
Register to forums    Log in

 
FORUMS Community Talk, Chatter & Stuff The Lounge 
Thread started 17 Dec 2006 (Sunday) 11:05
Search threadPrev/next
sponsored links (only for non-logged)

anyone good with php coding ?

 
dpurslow
Senior Member
Avatar
783 posts
Joined Jun 2005
Location: Haverfordwest - West Wales UK
     
Dec 17, 2006 11:05 |  #1

Hi there,

I am in need of a little help.

I am updating a form on a site an its a selfcontained mail form that once the form is posted it echo's stuff to the screen using this code.

if (mail($recipient, $subject, $msg))
echo nl2br("<b>Message Sent:</b>
Thanks for your enquiry");
else
echo "Message failed to send";

I would like it to redirect to a webpage if there are no errors so instead of getting the Message Sent...... stuff echoed to the screen, it redirects to a new page.

anyone know the line of script I am needing please.

thanks.


Regards,
David Purslow
07799 666808
/EMAIL] (external link)Birmingham Wedding Photographer (external link)

  
  LOG IN TO REPLY
PacAce
Cream of the Crop
Avatar
26,900 posts
Likes: 40
Joined Feb 2003
Location: Keystone State, USA
     
Dec 17, 2006 13:09 |  #2

This should do what you want:

....
if (mail($recipient, $subject, $msg))
{
?>

<html xmlns="http://www.w3.o​rg/1999/xhtml">
<head>
<title>
</title>
</head>
<body>
<script language="javascript">
<!--

window.location.href="​your-page.htm" // Replace your-page.htm with the name of the page or script you want to redirect to

// -->
</script>
</body>
</html>

<?php
}

else
echo "Message failed to send";
....


...Leo

  
  LOG IN TO REPLY
dpurslow
THREAD ­ STARTER
Senior Member
Avatar
783 posts
Joined Jun 2005
Location: Haverfordwest - West Wales UK
     
Dec 17, 2006 14:10 |  #3

Leo,

Thanks, - Would I put my page between between the head tags or is the your-page.htm a page that opens in the parent window or in a new window ?


Regards,
David Purslow
07799 666808
/EMAIL] (external link)Birmingham Wedding Photographer (external link)

  
  LOG IN TO REPLY
PacAce
Cream of the Crop
Avatar
26,900 posts
Likes: 40
Joined Feb 2003
Location: Keystone State, USA
     
Dec 17, 2006 14:31 |  #4

What you would need to do is replace the your-page.htm in the code with the URL you want to redirect to and that page will appear on the same window. If what you want to do is to pop up a new window, then you'll need to use a different code for that (and it wouldn't be called "redirecting").


...Leo

  
  LOG IN TO REPLY
tim
Light Bringer
Avatar
51,010 posts
Likes: 375
Joined Nov 2004
Location: Wellington, New Zealand
     
Dec 17, 2006 17:12 |  #5

www.phpbuilder.com (external link) forums are a great help.


Professional wedding photographer, solution architect and general technical guy with multiple Amazon Web Services certifications.
Read all my FAQs (wedding, printing, lighting, books, etc)

  
  LOG IN TO REPLY
PacAce
Cream of the Crop
Avatar
26,900 posts
Likes: 40
Joined Feb 2003
Location: Keystone State, USA
     
Dec 17, 2006 23:12 |  #6

dpurslow wrote in post #2412060 (external link)
Leo,

Thanks, - Would I put my page between between the head tags or is the your-page.htm a page that opens in the parent window or in a new window ?

Let me clarify my previous post. The page you want to redirect to would be a stand-alone html page (or a php script, for that matter). And whatever name you give that page or script is what you would use in place of your-page.htm in the code I provided above. Hope that makes more sense now. Sorry I didn't explain it as clearly previously. :)


...Leo

  
  LOG IN TO REPLY
dpurslow
THREAD ­ STARTER
Senior Member
Avatar
783 posts
Joined Jun 2005
Location: Haverfordwest - West Wales UK
     
Dec 18, 2006 06:10 |  #7

PacAce wrote in post #2414075 (external link)
Let me clarify my previous post. The page you want to redirect to would be a stand-alone html page (or a php script, for that matter). And whatever name you give that page or script is what you would use in place of your-page.htm in the code I provided above. Hope that makes more sense now. Sorry I didn't explain it as clearly previously. :)

Leo,

Fantastic thank you very much, muddled thru the best I could but this part was killing me - need to get a good teach your self php book !

thanks much !


Regards,
David Purslow
07799 666808
/EMAIL] (external link)Birmingham Wedding Photographer (external link)

  
  LOG IN TO REPLY
dpurslow
THREAD ­ STARTER
Senior Member
Avatar
783 posts
Joined Jun 2005
Location: Haverfordwest - West Wales UK
     
Dec 18, 2006 06:57 |  #8

Thanks,

I stripped out a litte of the code since it was not on a new page and its all working perfectly - it was a GREAT help :-)


Regards,
David Purslow
07799 666808
/EMAIL] (external link)Birmingham Wedding Photographer (external link)

  
  LOG IN TO REPLY
GilesGuthrie
Goldmember
Avatar
1,103 posts
Joined Jul 2006
Location: Edinburgh, UK
     
Dec 18, 2006 12:16 |  #9

Actually, the window.location.href directive is not supported by all browsers. Instead, substitute the entire Javacript above with:

<meta http-equiv="refresh" content="[delay in seconds];URL=[yourpage​.htm]" />

That's the compliant way of doing it, and even works in the uber-finnicky Safari.


Blipfoto (external link) - Flickr (external link) - Twitter (external link)
Canon EOS 1d X, 1d MkIII, 5d. Gear List

  
  LOG IN TO REPLY
sponsored links (only for non-logged)

924 views & 0 likes for this thread, 4 members have posted to it.
anyone good with php coding ?
FORUMS Community Talk, Chatter & Stuff The Lounge 
AAA
x 1600
y 1600

Jump to forum...   •  Rules   •  Forums   •  New posts   •  RTAT   •  'Best of'   •  Gallery   •  Gear   •  Reviews   •  Member list   •  Polls   •  Image rules   •  Search   •  Password reset   •  Home

Not a member yet?
Register to forums
Registered members may log in to forums and access all the features: full search, image upload, follow forums, own gear list and ratings, likes, more forums, private messaging, thread follow, notifications, own gallery, all settings, view hosted photos, own reviews, see more and do more... and all is free. Don't be a stranger - register now and start posting!


COOKIES DISCLAIMER: This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies and to our privacy policy.
Privacy policy and cookie usage info.


POWERED BY AMASS forum software 2.58forum software
version 2.58 /
code and design
by Pekka Saarinen ©
for photography-on-the.net

Latest registered member was a spammer, and banned as such!
2578 guests, 93 members online
Simultaneous users record so far is 15,144, that happened on Nov 22, 2018

Photography-on-the.net Digital Photography Forums is the website for photographers and all who love great photos, camera and post processing techniques, gear talk, discussion and sharing. Professionals, hobbyists, newbies and those who don't even own a camera -- all are welcome regardless of skill, favourite brand, gear, gender or age. Registering and usage is free.