Jump to content

Form Processing


baccarak

Recommended Posts

What I know on php you can write on the back of a postage stamp but I am a keen learner and appreciate any help or suggestions on this first hiccup......I have this form:

 

As you can see it is mailed to my subscription list manager (?subscribe) and data held in a flatfile db. This is perfect but does not have the facility to autorespond and notify me of this new subscriber so I have another script to handle this. through process.php.

 

What I want to do is to method=post the info (name and email) in the form to both the subscribe and the  process.php in the same button click, is this possible?

 

If it is, it will be invaluable to me

 

echo "<form method=post action=?action=subscribe>";

echo "<Table width=80%><TR><TD width=15%>Name:</TD><TD width=80%><input type='text' name='name' style='font-size:12px'></TD></TR><TR><TD width=15%>Email:</TD><TD width=80%><input type='text' name='email' style='font-size:12px'></TD></TR><TR><TD width=15%><input type=hidden name=group value='$group'><BR><BR></TD><TD width=80%><input type='submit' value='Subscribe' style='font-size:12px'></TD></TR></Table></form>";

 

Thanks for looking - there is nothing on the web about this (I have looked!!!...lol) but I certain it could help some one else.

Link to comment
https://forums.phpfreaks.com/topic/146795-form-processing/
Share on other sites

<?php

if(isset($_POST['NameOfSubmitButton'])){
   // form has been submitted .... process the form now.
}else{
// show form here... it has not been submitted
   echo '<form name="formName" action="'.$_SERVER['PHP_SELF'].'" method="post">';
// rest of form here
}
?>

 

This is basically how you would want to do it.

 

Nate

Link to comment
https://forums.phpfreaks.com/topic/146795-form-processing/#findComment-770730
Share on other sites

[quote

<?php

if(isset($_POST['NameOfSubmitButton'])){
  // form has been submitted .... process the form now.
}else{
// show form here... it has not been submitted
  echo '<form name="formName" action="'.$_SERVER['PHP_SELF'].'" method="post">';
// rest of form here
}
?>

 

This is basically how you would want to do it.

 

Nate

 

How would I add this to this code?

 

echo "<form method=post action=?action=subscribe>";
echo "<Table width=80%><TR><TD width=15%>Name:</TD><TD width=80%><input type='text' name='name' style='font-size:12px'></TD></TR><TR><TD width=15%>Email:</TD><TD width=80%><input type='text' name='email' style='font-size:12px'></TD></TR><TR><TD width=15%><input type=hidden name=group value='$group'><BR><BR></TD><TD width=80%><input type='submit' value='Subscribe' style='font-size:12px'></TD></TR></Table></form>";

 

how would this work? I would be interested to know

 

Kind Regards

Link to comment
https://forums.phpfreaks.com/topic/146795-form-processing/#findComment-770755
Share on other sites

<?php

if(isset($_POST['SUBSCRIBE'])){
   echo 'Form Submitted.... Add your processing code here<br />';

    echo '<pre>'; print_r($_POST); echo '</pre>';
}else{
   echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo "<Table width=80%>
<TR>
  <TD width=15%>Name:</TD>
  <TD width=80%><input type='text' name='name' style='font-size:12px'></TD>
</TR>
<TR>
  <TD width=15%>Email:</TD>
  <TD width=80%><input type='text' name='email' style='font-size:12px'></TD>
</TR>
<TR>
  <TD width=15%><input type=hidden name=group value='$group'><BR><BR></TD>
  <TD width=80%><input NAME="SUBSCRIBE" type='submit' value='Subscribe' style='font-size:12px'></TD>
</TR>
</Table>
</form>";
}
?>

 

Make sure your HTML is proper. Surround your attributes with quotes, and give all your form elements a name.

 

This is the basis for making a 1 page form / form processing page.

 

Nate

Link to comment
https://forums.phpfreaks.com/topic/146795-form-processing/#findComment-770771
Share on other sites

<?php

if(isset($_POST['SUBSCRIBE'])){
   echo 'Form Submitted.... Add your processing code here<br />';

    echo '<pre>'; print_r($_POST); echo '</pre>';
}else{
   echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo "<Table width=80%>
<TR>
  <TD width=15%>Name:</TD>
  <TD width=80%><input type='text' name='name' style='font-size:12px'></TD>
</TR>
<TR>
  <TD width=15%>Email:</TD>
  <TD width=80%><input type='text' name='email' style='font-size:12px'></TD>
</TR>
<TR>
  <TD width=15%><input type=hidden name=group value='$group'><BR><BR></TD>
  <TD width=80%><input NAME="SUBSCRIBE" type='submit' value='Subscribe' style='font-size:12px'></TD>
</TR>
</Table>
</form>";
}
?>

 

Make sure your HTML is proper. Surround your attributes with quotes, and give all your form elements a name.

 

This is the basis for making a 1 page form / form processing page.

 

Nate

 

 

this is ok to post to subscribe.php but where is the reference in posting to the proccess.php too? (Posting to 2 files not just the one)

 

Regards

Link to comment
https://forums.phpfreaks.com/topic/146795-form-processing/#findComment-770774
Share on other sites

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.