Email order Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Email order Form

Post by donny »

hello

i want to be able to email a customer a order form through email and have them send it back via email

i then want to have something where i copy and past the email form onto a form on my page and the php will separate what their input is and put them all into variables so i can store them on my db .

example

name: %NAME% YOUR NAME HERE %NAME%
address %ADDRESS% YOUR ADDRESS HERE %ADDRESS%
zip %ZIP% ZIP CODE HERE %ZIP%
state %STATE% STATE HERE %STATE%

i basically want to send them something like that and then copy and paste their filled out form and have my code put whatever they put in between the fields will be separated and put into a variable

for example
i copy and paste this into my form

name: %NAME% robert %NAME%
address %ADDRESS% 55 sesame street %ADDRESS%
zip %ZIP% 90210 %ZIP%
state %STATE% florida %STATE%


form turns it into this

Code: Select all

<?
$name = robert;
$address = 55 sesame street;
$zip = 90210;
state = florida;
?>
the whole % thing is just an example of something that can identify between marks, idk just my imagination..

can somebody help me with something like this please?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Email order Form

Post by Celauran »

Save that block as a template and use str_replace on it.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

can you show me an example for 1 field please
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Email order Form

Post by Celauran »

Something like

Code: Select all

$template = str_replace('%USERNAME%', $user->name, $template);
Where $template contains the email template you've read in from a file or the DB.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

how can i do other fields ? also will i need to enclose it in %USERNAME% ? i don't get how this would work using my template

i will send them this in a email

name: %NAME% YOUR NAME HERE %NAME%
address %ADDRESS% YOUR ADDRESS HERE %ADDRESS%



they will send this back

name: %NAME% ROBERT JONES %NAME%
address %ADDRESS% 123 SESAME STREET %ADDRESS%

i want to make it into variables like this

$name = "Robert Jones";
$address = "123 Sesame Street";
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

i used the code you made but $template shows everything else in the template. it strips the %USERNAME% fields but leaves everything after it
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

if somebody can please help me with code that will do the above id be very grateful!!!!!!!!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Email order Form

Post by Celauran »

donny wrote:how can i do other fields ? also will i need to enclose it in %USERNAME% ? i don't get how this would work using my template

i will send them this in a email

name: %NAME% YOUR NAME HERE %NAME%
address %ADDRESS% YOUR ADDRESS HERE %ADDRESS%



they will send this back

name: %NAME% ROBERT JONES %NAME%
address %ADDRESS% 123 SESAME STREET %ADDRESS%

i want to make it into variables like this

$name = "Robert Jones";
$address = "123 Sesame Street";
Any reason you're not using a form here? Would make life a lot easier. How are you planning on parsing the emails?
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

i am also using forms this is for people that cannot use the form and something i am using as a backup. people will email me with their info filled out. i will manually copy and paste the info. i want my code to process it how i showed in previous posts.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

this is going to be used for people that cannot use the web form. i want this as a another way to process forms via email . there may be better ways to do this but this is the way i am choosing to use as it will work for me. can anybody please help me by showing me an example of code for 2 fields i should be able to edit the script after that to make it work for the number of fields i need. thank you
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Email order Form

Post by Celauran »

It's not even clear to me what you're trying to do. You mentioned entering data manually, but you're still asking about these variables. What am I not getting here?
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

deleted
Last edited by donny on Mon Aug 25, 2014 5:44 pm, edited 1 time in total.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

deleted
Last edited by donny on Mon Aug 25, 2014 5:44 pm, edited 1 time in total.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

deleted
Last edited by donny on Mon Aug 25, 2014 5:44 pm, edited 1 time in total.
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Email order Form

Post by donny »

deleted
Last edited by donny on Mon Aug 25, 2014 5:44 pm, edited 1 time in total.
Post Reply