Send value from one form to another...

User 2744602 Photo


Registered User
162 posts

Hi guys :)
Need some help :D

Does anybody know of a good tutorial or code to send values between .php forms please?

I would like to have a radio button checked on one form and then send it to the second form which is the contact form, with the rest of the details to fill in.

Any help would be great tx :)
KISS is the key!
User 187934 Photo


Senior Advisor
20,188 posts

You can use a url variable or a session variable. Are you using cc's form builder?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2744602 Photo


Registered User
162 posts

Hi Eric :)
No mate I use some other php services.

What I want to do is:
I may have been very bad at explain it, will try again.

I have a page with templates for selection, each has a radio button or it can be just a button, asking the person to make a selection, as long as it selects the value for that template.

I need it to then send that Templates value (template one say) to the other page which has all the contact information on it, that they can then fill in.

Name
Email
What you want field etc.

And I did find this:
template.php

<html>
<body>

<form action="site2.php" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="email">
<input type="submit">
</form>

</body>
</html>

contact.php

<html>
<body>

Hello <?php echo $_POST["name"]; ?>!<br>
Your mail is <?php echo $_POST["mail"]; ?>.

</body>
</html>

KISS is the key!
User 113083 Photo


Ambassador
251 posts

Hi Brett
Maybe you could use http://www.zapier.com for your needs.
Good luck.
Sincerely Peter
User 187934 Photo


Senior Advisor
20,188 posts

On template.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<form action="contact.php" method="post">

Template One: <input type="radio" name="template" value="1">
Template two: <input type="radio" name="template" value="2">
<input type="submit">
</form>

</body>
</html>

On contact.php.
<?php
session_start();
$_SESSION['template'] = $_POST['template'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>

<form action="contact_proccess.php" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="email">
Template # <?php if(isset($_SESSION['template'])){echo $_SESSION['template']; }?> : <input type="radio" name="template" value="<?php if(isset($_SESSION['template'])){echo $_SESSION['template']; }?>" <?php if(isset($_SESSION['template'])){echo 'checked="checked"'; }?> >
<input type="submit">
</form>
<?php
unset($_SESSION['template']);
?>
</body>
</html>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2744602 Photo


Registered User
162 posts

Nice mate thank you! I will pop that in Cheers!

Eric Rohloff wrote:
On template.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<form action="contact.php" method="post">

Template One: <input type="radio" name="template" value="1">
Template two: <input type="radio" name="template" value="2">
<input type="submit">
</form>

</body>
</html>

On contact.php.
<?php
session_start();
$_SESSION['template'] = $_POST['template'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>

<form action="contact_proccess.php" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="email">
Template # <?php if(isset($_SESSION['template'])){echo $_SESSION['template']; }?> : <input type="radio" name="template" value="<?php if(isset($_SESSION['template'])){echo $_SESSION['template']; }?>" <?php if(isset($_SESSION['template'])){echo 'checked="checked"'; }?> >
<input type="submit">
</form>
<?php
unset($_SESSION['template']);
?>
</body>
</html>
KISS is the key!
User 2744602 Photo


Registered User
162 posts

Rattle wrote:
Hi Brett
Maybe you could use http://www.zapier.com for your needs.
Good luck.
Sincerely Peter


Thanks Peter !! I will check this out.

Cheers Brett
KISS is the key!

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.