Jump to content

Forms


jwk811

Recommended Posts

Hey guys!

I need some help, hoping you might know the answer. With my forms I would like to know if there is a way I can make it so the information submitted into the form can be caught on more than one page. Mostly so the information submitted can go to another page for verification and once the information is comfirmed I would like an email. I know how to set up the email thing but how will I make the form action have more than one action?
Link to comment
Share on other sites

Why would you want to have more than one action?  Your information would go to one page for verification, and at the same time be emailed, so verification would do no good.

Combine the two into one...have the initial part verify the data, if it's bad, ask the user to reenter.  If it's good, then send an email.
Link to comment
Share on other sites

No. I need the information submitted in the form to be pulled up on the next page for verification then once they submit the form they will go to a new page where they can verify the data and then confirm it. Once confirmed I would like the data to be emailed to me. I kind of know how to do that already but after they confirm the data I would like that data to be caught on ANOTHER page, because the user would be going to different steps. Like this: Step One-Fill out form, Step Two-Verify data, Step Three.... and on step three the data inputted would still need to be caught on that page as well as step four. I think it has to do with sessions or cookies but have no clue how to set this up. I use GoDaddy's server and asked them about it and they said it had something to do with custom forms but had nothing else to say. Please help me!
Link to comment
Share on other sites

Here,

this code is what i,ve just used.
Change the variables to the vars in your for.
Change the database stuff to yours.
and echo out $strError, $ok and $notOk somwhere in the page.

This will give full form validation, and email the user what ever you want. all in the same page.

Before HTML
[code]
<?php

$arrErrors = array();

if (!empty($_POST['Submit'])) {
if ($_POST['username']== "")
$arrErrors['username'] = "Add Username";
if ($_POST['password']== "")
$arrErrors['password'] = "Add Password";

if (count($arrErrors) == 0) {

$username=addslashes($_POST['username']);
$password=addslashes($_POST['password']);


$query2 = "SELECT username FROM user_info WHERE username = '$username'";
$result2 = mysql_query($query2) or die ("query 2 failed");
$count = mysql_num_rows($result2);

if ($count == 0) {
$sql = mysql_query("INSERT INTO user_info (username, password)
VALUES ('$username', '$password')") or die ("could not insert");
if ($sql) {
$_POST = array();
$ok = 'Your Details have been updated,<br>
An email has been sent to you with your login details.';
$link = '<a href="http://www.theeventorganiser.com/login.php">login</a>';
$to      = $email;
$subject = 'Hi '.$first_name.', The Event Organiser Would like to thank you';
$message = 'Hi '.$first_name.'<br>
Thank you for Signing up to he Event Organiser<br><br>
Here is you username and password<br>
USERNAME = '.$username.'<br>
PASSWORD = '.$password.'<br><br>
Please login here<br>'.$link.'';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);

} else {
$notOk = "Sorry, there was an Error";
}
} else {
$userTaken = 'Sorry, The username has already been taken. <br> Please select another one.';
}

} else {
if (empty($username) || empty($password)) {
foreach ($arrErrors as $error) {

$strError .= '<div class="error">';
$strError .= "<li>$error</li>";
}
$strError .= '</div>';
}
}

}

?>
[/code]


Place Somewhere in the HTML
[code]
<form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<table width="185" height="102" border="0" cellspacing="0" cellpadding="0" background="JPGS/tags/members.jpg">
<tr>
    <td valign="middle">
<center>
 <table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="#e5eaee">
         <tr>
           <td colspan="3">
<div align="center" class="layerText">MEMBERS AREA </div>
</td>
         </tr>
         <tr>
           <td class="small2">
&nbsp;&nbsp;Login:
</td>
           <td colspan="2">
<div align="left">
             <input name="username" type="text" size="14" id="username" value="<?php $_POST['username']; ?>">
           </div></td>
         </tr>
         <tr>
           <td class="small2">
&nbsp;&nbsp;Password:
</td>
           <td colspan="2">
<div align="left">
             <input name="password" type="password" size="14" id="password" value="<?php $_POST['password']; ?>">
           </div></td>
         </tr>
         <tr>
           <td colspan="3">

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="112"><a href="forgot_your_password.php" class="link">Forgot your password?</a>
</td>
<td width="64" valign="middle">

<input name="Submit" type="submit" value="Submit">
</td>
</tr>
</table>

</td>
         </tr>
     </table>
 </center>
 </td>
  </tr>
</table>
</form>
[/code]


Hope that helps
Link to comment
Share on other sites

Okay, I think that will help me. Thank you very much. But this is very hard for me to understand as I am very new to all of this. I will try to figure it out but if you could make it a little simpler so I can understand it better then that will be great! Thank you either way!
Link to comment
Share on other sites

in a nut shell.


the HTML code goes into the body section of your code.
The form (in this example) has two fields (username & password).
when the user enters in his info and hit submit. The form sends the info back to the top of the page, using the line.
[code]
  <form name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
[/code]

Then, at the top of the php code, you create an emtpy array: $arrErrors = array()
Then, we check to see if the field was emtpy, if not then place the user value into the empty array, using the -
[code]
if ($_POST['username']== "")
$arrErrors['username'] = "Add Username";
if ($_POST['password']== "")
$arrErrors['password'] = "Add Password";
[/code]

So, you will need to make the username above match the input field in the HTML (below).
[code]
<input name="username" type="text" size="14" id="username" value="<?php $_POST['username']; ?>">
[/code]

If you want a 'name' field for example, change all of the usernames to name.

Then you want to check if all feilds are filled in, then insert into your database table.
[code]
if (count($arrErrors) == 0) {

$username=addslashes($_POST['username']);
$password=addslashes($_POST['password']);

$sql = mysql_query("INSERT INTO user_info (username, password)
VALUES (''$username', '$password')") or die ("could not insert");
[/code]

Now that is done you want to send your self an email to let you know.

[code]
if ($sql) {
$_POST = array();
$ok = 'Your Details have been updated,<br>
An email has been sent to you with your login details.';
$link = '<a href="http://www.theeventorganiser.com/login.php">login</a>';
$to      = $email;
$subject = 'Hi '.$first_name.', The Event Organiser Would like to thank you';
$message = 'Hi '.$first_name.'<br>
Thank you for Signing up to the Event Organiser<br><br>
Here is you username and password<br>
USERNAME = '.$username.'<br>
PASSWORD = '.$password.'<br><br>
Please login here<br>'.$link.'';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);
[/code]
Some thing like this, just change the $email, to your email address.

and thats it.

Dont forget to do this:
[code]
<BODY>
  <?php echo $strError; ?>
   <?php echo $ok; ?>
    <?php echo $notOk; ?>
<?php echo $userTaken; ?>
</BODY
[/code]
Where you want you info to be displayed.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.