Jump to content

[SOLVED] Php Forms fwrite and form action question. Very stuck!


Snooble

Recommended Posts

Hello everone, This is my first post and request for help. .php is my weak point.

I'm creating a register page, but the information is to be saved to a .txt file.

So far:

[code]
<?php
$pass = $_POST['pass'];
$email = $_POST['email'];
$passtwo = $_POST['passtwo'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$llno = $_POST['llno'];
$mobno = $_POST['mobno'];
$addno = $_POST['addno'];
$addone = $_POST['addone'];
$addtwo = $_POST['addtwo'];
$addthree = $_POST['addthree'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$other = $_POST['other'];
$sthree = $_POST['sthree'];
$country = $_POST['country'];
$date = date("g:i a");
$submit = $_POST['submit'];
if (isset($pass) && isset($email)){
$fp = fopen('1.txt', 'a+');
fwrite($fp, "Time: ".$date."\nEmail: ".$email."\nPass: ".$pass."\nPass Confirm: ".$passtwo."\nFirst Name: ".$fname."\nSurname: ".$sname."\nLL Number: ".$llno."\nMob: ".$mobno."\nHouse No/Name: ".$addno."\nAddress line 1: ".$addone."\nAddress line 2: ".$addtwo."\nAddress Line 3: ".$addthree."\nCity/Town: ".$city."\nPost Code: ".$postcode. "\nCountry, Other: ".$other."\nTitle :".$sthree."\nCountry: ".$country."\n\n");
fclose($fp);
echo '<form method="post"><div align="center"><br />
              <br />
              <table width="100%" height="854" border="0" cellpadding="0" cellspacing="1">

                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Email Address:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="text" name="email" /></td>
                </tr>
               
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Create Password:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="passtwo" /></td>
                </tr>
                <tr>
                  <td height="17" class="style40"><div align="right" class="style3">Re-enter Password:</div></td>
                  <td height="17" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="pass" /></td>
                </tr>
                <tr>
                  <td height="35" class="style40 style2 style4">&nbsp;</td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40">&nbsp;</td>
                </tr>
               
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Title</div></td>
                  <td width="12" height="35"><br />
                      <br />                  </td>
                  <td height="35" colspan="2"><span class="style40">
                  <select name="sthree">
                      <option>Choose</option>
                      <option>Mr</option>
                      <option>Mrs</option>
                      <option>Ms</option>
                      <option>Miss</option>
                      <option>Dr</option>
                      <option>Rev</option>
                      <option>Sir</option>
                    </select>
                  </span></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">First Name:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="sname" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Surname:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="llno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Landline Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="mobno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Mobile Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Property Name / Number: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addone" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 1: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addtwo" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 2: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addthree" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Address Line 3: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="city" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">City / Town:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input name="postcode" type="text" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Postal Code:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="fname" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Country:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><select name="country">
                    <option selected="selected">Choose</option>
                    <option>United Kingdom</option>
                    <option>United States</option>
                    <option>Canada</option>
                    <option>Other</option>
                  </select>                  </td>
                </tr>
                <tr>
                  <td width="420" height="7" class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td height="7" colspan="2"><span class="style40 style1">(Leave blank if country chosen)</span></td>
                </tr>
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Other: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="other2" /></td>
                </tr>
                <tr>
                  <td class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td width="315" height="52">&nbsp;</td>
                  <td width="133"><input type="image" src="register.gif" name="submit" alt="Log In" value="Log In" /></td>
                </tr>
              </table>
              <p align="center"><br />
                <br />
                <br />
    </p>
              </div>
                    </td>
      </tr></form>';
}elseif (isset($submit)){    
echo '<form method="post"><div align="center"><br />
              <br />
              <table width="100%" height="854" border="0" cellpadding="0" cellspacing="1">

                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Email Address:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="text" name="email" /></td>
                </tr>
               
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Create Password:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="passtwo" /></td>
                </tr>
                <tr>
                  <td height="17" class="style40"><div align="right" class="style3">Re-enter Password:</div></td>
                  <td height="17" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="pass" /></td>
                </tr>
                <tr>
                  <td height="35" class="style40 style2 style4">&nbsp;</td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40">&nbsp;</td>
                </tr>
               
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Title</div></td>
                  <td width="12" height="35"><br />
                      <br />                  </td>
                  <td height="35" colspan="2"><span class="style40">
                  <select name="sthree">
                      <option>Choose</option>
                      <option>Mr</option>
                      <option>Mrs</option>
                      <option>Ms</option>
                      <option>Miss</option>
                      <option>Dr</option>
                      <option>Rev</option>
                      <option>Sir</option>
                    </select>
                  </span></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">First Name:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="sname" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Surname:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="llno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Landline Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="mobno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Mobile Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Property Name / Number: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addone" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 1: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addtwo" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 2: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addthree" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Address Line 3: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="city" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">City / Town:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input name="postcode" type="text" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Postal Code:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="fname" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Country:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><select name="country">
                    <option selected="selected">Choose</option>
                    <option>United Kingdom</option>
                    <option>United States</option>
                    <option>Canada</option>
                    <option>Other</option>
                  </select>                  </td>
                </tr>
                <tr>
                  <td width="420" height="7" class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td height="7" colspan="2"><span class="style40 style1">(Leave blank if country chosen)</span></td>
                </tr>
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Other: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="other2" /></td>
                </tr>
                <tr>
                  <td class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td width="315" height="52">&nbsp;</td>
                  <td width="133"><input type="image" src="register.gif" name="submit" alt="Log In" value="Log In" /></td>
                </tr>
              </table>
              <p align="center"><br />
                <br />
                <br />
    </p>
              </div>
                    </td>
      </tr></form>';
}else{
echo '<form method="post"><div align="center"><br />
              <br />
              <table width="100%" height="854" border="0" cellpadding="0" cellspacing="1">

                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Email Address:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="text" name="email" /></td>
                </tr>
               
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Create Password:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="passtwo" /></td>
                </tr>
                <tr>
                  <td height="17" class="style40"><div align="right" class="style3">Re-enter Password:</div></td>
                  <td height="17" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="pass" /></td>
                </tr>
                <tr>
                  <td height="35" class="style40 style2 style4">&nbsp;</td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40">&nbsp;</td>
                </tr>
               
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Title</div></td>
                  <td width="12" height="35"><br />
                      <br />                  </td>
                  <td height="35" colspan="2"><span class="style40">
                  <select name="sthree">
                      <option>Choose</option>
                      <option>Mr</option>
                      <option>Mrs</option>
                      <option>Ms</option>
                      <option>Miss</option>
                      <option>Dr</option>
                      <option>Rev</option>
                      <option>Sir</option>
                    </select>
                  </span></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">First Name:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="sname" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Surname:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="llno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Landline Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="mobno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Mobile Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Property Name / Number: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addone" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 1: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addtwo" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 2: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addthree" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Address Line 3: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="city" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">City / Town:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input name="postcode" type="text" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Postal Code:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="fname" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Country:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><select name="country">
                    <option selected="selected">Choose</option>
                    <option>United Kingdom</option>
                    <option>United States</option>
                    <option>Canada</option>
                    <option>Other</option>
                  </select>                  </td>
                </tr>
                <tr>
                  <td width="420" height="7" class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td height="7" colspan="2"><span class="style40 style1">(Leave blank if country chosen)</span></td>
                </tr>
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Other: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="other2" /></td>
                </tr>
                <tr>
                  <td class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td width="315" height="52">&nbsp;</td>
                  <td width="133"><input type="image" src="register.gif" name="submit" alt="Log In" value="Log In" /></td>
                </tr>
              </table>
              <p align="center"><br />
                <br />
                <br />
    </p>
              </div>
                    </td>
      </tr></form>';
}
?>[/code]


I believe that should work fine as the table names match the Post values.

BUT. I want the form to not only write the information but the submit button to take the user to the second part of the registration. I've tried adding the action="register2.php". But the information only writes using modzilla and not IE. I'm really stuck here.

Whilst i ask, would it be possible to create validation on the form also, eg. check the passwords are the same. and required fields.

The code might seem long but it is all the same as i dont really know where to go from here.

Thank you,

Sam
Link to comment
Share on other sites

Second part is the "information sent" page. I need to be able to put it on a memory stick.

But it works without the action tag. it saves the information to the text file. BUT! I dont know how to make it send me to a different page also. Any help?

thank you for you comments though!

Snooble
Link to comment
Share on other sites

Honestly... this code is a mess.

The code which inserts into the txt fiile really ought to be after the form and within an if() statement so that it only runs if the form has been submitted.

If you put error reporting on this code would be spitting out plenty of Notices.

Once you get the logic correct....

[code=php:0]
if (!isset($_POST['submit'])) {
  // show form
} else {
  // insert into txt file.
}
[/code]

then its easy to add a redirect using the [url=http://php.net/header]header[/url] function. eg;


[code=php:0]
if (!isset($_POST['submit'])) {
  // show form
} else {
  // insert into txt file.
  header("Location: success.php");
}
[/code]
Link to comment
Share on other sites

Thank you. Thats easy enough for me to understand! Brilliant. So for clarification:

[code]<?php
$pass = $_POST['pass'];
$email = $_POST['email'];
$passtwo = $_POST['passtwo'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$llno = $_POST['llno'];
$mobno = $_POST['mobno'];
$addno = $_POST['addno'];
$addone = $_POST['addone'];
$addtwo = $_POST['addtwo'];
$addthree = $_POST['addthree'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$other = $_POST['other'];
$sthree = $_POST['sthree'];
$country = $_POST['country'];
$date = date("g:i a");
$submit = $_POST['submit'];
if (!isset($_POST['submit'])) {
echo '<form method="post"><div align="center"><br />
              <br />
              <table width="100%" height="854" border="0" cellpadding="0" cellspacing="1">

                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Email Address:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="text" name="email" /></td>
                </tr>
               
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Create Password:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="passtwo" /></td>
                </tr>
                <tr>
                  <td height="17" class="style40"><div align="right" class="style3">Re-enter Password:</div></td>
                  <td height="17" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="pass" /></td>
                </tr>
                <tr>
                  <td height="35" class="style40 style2 style4">&nbsp;</td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40">&nbsp;</td>
                </tr>
               
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Title</div></td>
                  <td width="12" height="35"><br />
                      <br />                  </td>
                  <td height="35" colspan="2"><span class="style40">
                  <select name="sthree">
                      <option>Choose</option>
                      <option>Mr</option>
                      <option>Mrs</option>
                      <option>Ms</option>
                      <option>Miss</option>
                      <option>Dr</option>
                      <option>Rev</option>
                      <option>Sir</option>
                    </select>
                  </span></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">First Name:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="sname" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Surname:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="llno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Landline Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="mobno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Mobile Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Property Name / Number: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addone" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 1: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addtwo" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 2: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addthree" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Address Line 3: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="city" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">City / Town:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input name="postcode" type="text" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Postal Code:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="fname" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Country:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><select name="country">
                    <option selected="selected">Choose</option>
                    <option>United Kingdom</option>
                    <option>United States</option>
                    <option>Canada</option>
                    <option>Other</option>
                  </select>                  </td>
                </tr>
                <tr>
                  <td width="420" height="7" class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td height="7" colspan="2"><span class="style40 style1">(Leave blank if country chosen)</span></td>
                </tr>
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Other: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="other2" /></td>
                </tr>
                <tr>
                  <td class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td width="315" height="52">&nbsp;</td>
                  <td width="133"><input type="image" src="register.gif" name="submit" alt="Log In" value="Log In" /></td>
                </tr>
              </table>
              <p align="center"><br />
                <br />
                <br />
    </p>
              </div>
                    </td>
      </tr></form>';
} else {
$fp = fopen('1.txt', 'a+');
fwrite($fp, "Time: ".$date."\nEmail: ".$email."\nPass: ".$pass."\nPass Confirm: ".$passtwo."\nFirst Name: ".$fname."\nSurname: ".$sname."\nLL Number: ".$llno."\nMob: ".$mobno."\nHouse No/Name: ".$addno."\nAddress line 1: ".$addone."\nAddress line 2: ".$addtwo."\nAddress Line 3: ".$addthree."\nCity/Town: ".$city."\nPost Code: ".$postcode. "\nCountry, Other: ".$other."\nTitle :".$sthree."\nCountry: ".$country."\n\n");
fclose($fp);
header("Location: insertpagetobedirectedto.php");
}
?>[/code]

And that will save info and redirect user?

Thank you ever so much for your time. I did look into header but all i remember was "header already sent by, blah blah" And i have html on the page with the .php embed.

Snooble.

Thank you.
Link to comment
Share on other sites

[quote]And that will save info and redirect user?[/quote]

Yes, but you should also move all this...

[code=php:0]
$pass = $_POST['pass'];
$email = $_POST['email'];
$passtwo = $_POST['passtwo'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$llno = $_POST['llno'];
$mobno = $_POST['mobno'];
$addno = $_POST['addno'];
$addone = $_POST['addone'];
$addtwo = $_POST['addtwo'];
$addthree = $_POST['addthree'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$other = $_POST['other'];
$sthree = $_POST['sthree'];
$country = $_POST['country'];
$date = date("g:i a");
$submit = $_POST['submit'];
[/code]

into the [i]else[/i] part of your script.
Link to comment
Share on other sites

[code]<?php
if (!isset($_POST['submit'])) {
echo '<form method="post"><div align="center"><br />
              <br />
              <table width="100%" height="854" border="0" cellpadding="0" cellspacing="1">

                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Email Address:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="text" name="email" /></td>
                </tr>
               
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Create Password:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="passtwo" /></td>
                </tr>
                <tr>
                  <td height="17" class="style40"><div align="right" class="style3">Re-enter Password:</div></td>
                  <td height="17" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="pass" /></td>
                </tr>
                <tr>
                  <td height="35" class="style40 style2 style4">&nbsp;</td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40">&nbsp;</td>
                </tr>
               
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Title</div></td>
                  <td width="12" height="35"><br />
                      <br />                  </td>
                  <td height="35" colspan="2"><span class="style40">
                  <select name="sthree">
                      <option>Choose</option>
                      <option>Mr</option>
                      <option>Mrs</option>
                      <option>Ms</option>
                      <option>Miss</option>
                      <option>Dr</option>
                      <option>Rev</option>
                      <option>Sir</option>
                    </select>
                  </span></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">First Name:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="sname" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Surname:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="llno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Landline Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="mobno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Mobile Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Property Name / Number: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addone" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 1: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addtwo" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 2: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addthree" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Address Line 3: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="city" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">City / Town:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input name="postcode" type="text" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Postal Code:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="fname" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Country:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><select name="country">
                    <option selected="selected">Choose</option>
                    <option>United Kingdom</option>
                    <option>United States</option>
                    <option>Canada</option>
                    <option>Other</option>
                  </select>                  </td>
                </tr>
                <tr>
                  <td width="420" height="7" class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td height="7" colspan="2"><span class="style40 style1">(Leave blank if country chosen)</span></td>
                </tr>
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Other: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="other2" /></td>
                </tr>
                <tr>
                  <td class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td width="315" height="52">&nbsp;</td>
                  <td width="133"><input type="image" src="register.gif" name="submit" alt="Log In" value="Log In" /></td>
                </tr>
              </table>
              <p align="center"><br />
                <br />
                <br />
    </p>
              </div>
                    </td>
      </tr></form>';
} else {
$pass = $_POST['pass'];
$email = $_POST['email'];
$passtwo = $_POST['passtwo'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$llno = $_POST['llno'];
$mobno = $_POST['mobno'];
$addno = $_POST['addno'];
$addone = $_POST['addone'];
$addtwo = $_POST['addtwo'];
$addthree = $_POST['addthree'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$other = $_POST['other'];
$sthree = $_POST['sthree'];
$country = $_POST['country'];
$date = date("g:i a");
$submit = $_POST['submit'];
$fp = fopen('1.txt', 'a+');
fwrite($fp, "Time: ".$date."\nEmail: ".$email."\nPass: ".$pass."\nPass Confirm: ".$passtwo."\nFirst Name: ".$fname."\nSurname: ".$sname."\nLL Number: ".$llno."\nMob: ".$mobno."\nHouse No/Name: ".$addno."\nAddress line 1: ".$addone."\nAddress line 2: ".$addtwo."\nAddress Line 3: ".$addthree."\nCity/Town: ".$city."\nPost Code: ".$postcode. "\nCountry, Other: ".$other."\nTitle :".$sthree."\nCountry: ".$country."\n\n");
fclose($fp);
header("Location: insertpagetobedirectedto.php");
}
?>[/code]

Look good to you?

And thank you ever so much!!!!!

Snooble
Link to comment
Share on other sites

Sorry the script takes me back to square one.

Take a look: http://wezzsmusic.ifastnet.com/One%20Time%20Deals/register.php

If you press submit in IE it doesnt fwrite, it reloads the page. but in modzilla it does AND it does else command.

So. Full functuality in Modzilla, but IE doesnt do the else command on submit.

Sorry if i'm a nuisence but i'm really looking forward to learning why and improving.

Snooble
Link to comment
Share on other sites

You are using an image as the submit button, so you have to check to see if either $_POST['submit_x'] or $_POST['submit_y'] is set instead of just $_POST['submit']. $_POST['submit_x'] and $_POST['submit_y'] are the coordinates where you clicked the image.

Change the "if" statement to:
[code]<?php
if (!isset($_POST['submit_x'])) {
?>[/code]

Ken
Link to comment
Share on other sites

woh... Right... Bare in mind i've been learning the last few days.

[code]<?php
if (!isset($_POST['submit_x'])) {
?>[/code]

Do i need to replace "x" with anything? And why does the isset change for an image? i know you said to give the co-ordinates, but i'm still confused. nothing to do with the image size. how would i find the co-ordinates of the image on the page. Also! If it's important. The register.php file is opened with restraints. Check:

http://wezzsmusic.ifastnet.com/One%20Time%20Deals


And click register on right side. You'll see what i mean. Using javascript i limit window size and status.

If i changed submit to text instead of image would the script work? Just a side question.


Thank you ever so much.

Snooble
Link to comment
Share on other sites

You just have to test whether $_POST['submit_x'] or $_POST['submit_y'] is set. You don't need to know where the button was clicked. MSIE6 (and lower, I'm not sure about MSIE7) don't return the value of $_POST['submit'] for an image button.

If you want to see what is being returned to your script from the form, put this line at the start of your script:
[code]<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>[/code]

Ken
Link to comment
Share on other sites

I see. Well this is it. I thought i was on the right tracks as Firefox handled the form perfectly, it saved the information to the text file, AND sent me to the next page when i pressed submit. But Internet Explorer just sent me to next page and didnt save anything, nor even create the text file.

I hope that makes it clear? I just need the tweak that will make IE do the same? Possibly a few minor corrections. I'm sorry to be a pain but i really am lost when it comes to this. I know i can do it because i made a working 2 box version of the script just to test if i could make it write to files. And that worked perfectly. But problems have arrived with the new script and i can't see a difference apart from the names of the text fields. And i've treble checked them.

Thank you, but please i need a solution. As i need to know what to change, and what to change that to.

Plain and simple.

The whole .php file just up the page. I am willing to test anything.

Snooble
Link to comment
Share on other sites

This is my register.php:

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Secure :: One Time Deals :: Register </title>
<style type="text/css">
<!--
.style21 {font-family: ADMUI3Lg, serif, monospace, cursive; font-weight: bold; font-size: 16px; color: #FFFFFF; }
body {
margin: 0px;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 4px;
padding-left: 2px;
background-image: url(fbedc7.gif);
}
.style37 {
color: #FFFFFF;
font-size: 1px;
}
-->
</style>
</head>

<body>
<table width="100%" height="19%" border="0" background="fbedc7.gif">
  <tr>
    <td height="25" background="Untitled-4.gif"><div align="center"><span class="style21">Register</span></div></td>
  </tr>
  <tr>
    <td height="131" valign="top" background="fbedc7.gif"><table width="100%" height="0%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="100%" height="1" valign="top"><span class="style37">.</span></td>
        </tr>
      <tr>
        <td height="33" align="center" valign="middle" background="fbedc7.gif"><div align="center"><span xmlns:sitefunctions="urn:siteFunctions">&nbsp; </span><img src="shoppingbasketheader.gif" alt="Shopping Basket" xmlns:sitefunctions="urn:siteFunctions" align="absmiddle" height="24" width="215" />
        </div></td>
      </tr>
      <tr>
        <td height="8" valign="top" bgcolor="#FFFFFF"><div align="center"><span class="style37">.</span></div></td>
      </tr>
      <tr>
        <td height="11" valign="top" background="fbedc7.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="898" background="fbedc7.gif"><br />
<?php
if (!isset($_POST['submit_x'])) {
echo '<form method="post"><div align="center"><br />
              <br />
              <table width="100%" height="854" border="0" cellpadding="0" cellspacing="1">

                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Email Address:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="text" name="email" /></td>
                </tr>
               
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Create Password:</div></td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="passtwo" /></td>
                </tr>
                <tr>
                  <td height="17" class="style40"><div align="right" class="style3">Re-enter Password:</div></td>
                  <td height="17" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40"><input type="password" name="pass" /></td>
                </tr>
                <tr>
                  <td height="35" class="style40 style2 style4">&nbsp;</td>
                  <td height="35" class="style40">&nbsp;</td>
                  <td height="35" colspan="2" class="style40">&nbsp;</td>
                </tr>
               
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Title</div></td>
                  <td width="12" height="35"><br />
                      <br />                  </td>
                  <td height="35" colspan="2"><span class="style40">
                  <select name="sthree">
                      <option>Choose</option>
                      <option>Mr</option>
                      <option>Mrs</option>
                      <option>Ms</option>
                      <option>Miss</option>
                      <option>Dr</option>
                      <option>Rev</option>
                      <option>Sir</option>
                    </select>
                  </span></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">First Name:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="sname" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Surname:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="llno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Landline Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="mobno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Mobile Number:</div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addno" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Property Name / Number: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addone" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 1: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addtwo" /></td>
                </tr>
                <tr>
                  <td width="420" class="style40"><div align="right" class="style3">Address Line 2: </div></td>
                  <td width="12">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="addthree" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Address Line 3: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="city" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">City / Town:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input name="postcode" type="text" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Postal Code:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="fname" /></td>
                </tr>
                <tr>
                  <td width="420" height="35" class="style40"><div align="right" class="style3">Country:</div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><select name="country">
                    <option selected="selected">Choose</option>
                    <option>United Kingdom</option>
                    <option>United States</option>
                    <option>Canada</option>
                    <option>Other</option>
                  </select>                  </td>
                </tr>
                <tr>
                  <td width="420" height="7" class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td height="7" colspan="2"><span class="style40 style1">(Leave blank if country chosen)</span></td>
                </tr>
                <tr>
                  <td height="35" class="style40"><div align="right" class="style3">Other: </div></td>
                  <td width="12" height="35">&nbsp;</td>
                  <td height="35" colspan="2"><input type="text" name="other2" /></td>
                </tr>
                <tr>
                  <td class="style40">&nbsp;</td>
                  <td width="12">&nbsp;</td>
                  <td width="315" height="52">&nbsp;</td>
                  <td width="133"><input type="image" src="register.gif" name="submit" alt="Log In" value="Log In" /></td>
                </tr>
              </table>
              <p align="center"><br />
                <br />
                <br />
    </p>
              </div>
                    </td>
      </tr></form>';
} else {
$pass = $_POST['pass'];
$email = $_POST['email'];
$passtwo = $_POST['passtwo'];
$fname = $_POST['fname'];
$sname = $_POST['sname'];
$llno = $_POST['llno'];
$mobno = $_POST['mobno'];
$addno = $_POST['addno'];
$addone = $_POST['addone'];
$addtwo = $_POST['addtwo'];
$addthree = $_POST['addthree'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$other = $_POST['other'];
$sthree = $_POST['sthree'];
$country = $_POST['country'];
$date = date("g:i a");
$submit = $_POST['submit'];
$fp = fopen('1.txt', 'a+');
fwrite($fp, "Time: ".$date."\nEmail: ".$email."\nPass: ".$pass."\nPass Confirm: ".$passtwo."\nFirst Name: ".$fname."\nSurname: ".$sname."\nLL Number: ".$llno."\nMob: ".$mobno."\nHouse No/Name: ".$addno."\nAddress line 1: ".$addone."\nAddress line 2: ".$addtwo."\nAddress Line 3: ".$addthree."\nCity/Town: ".$city."\nPost Code: ".$postcode. "\nCountry, Other: ".$other."\nTitle :".$sthree."\nCountry: ".$country."\n\n");
fclose($fp);
echo ('Registration 2');
}
?>&nbsp;</td>
            </tr>
          </table>
          <div align="center"></div></td>
      </tr>
      <tr>
        <td height="19" align="center" valign="middle" background="fbedc7.gif" bgcolor="#FFFFFF"><span class="style37">a</span></td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</body>
</html>
[/code]

Ok. Evaluation...

Modzilla Firefox:
1. I enter information
2. Press submit
3. Information is sent to text file AND page now has "Registration 2" written on it.

Internet Explorer:
1. I enter information
2. Press submit
3. Nothing added to text file. AND page reloads input fields.


Modzilla = success

Internet Explorer = failure

Please help with fixing the code to work with internet explorer...

Or offer an alternative method as i've started from scratch SOO many times now.

Thank you for your help 'kenrbnsn' but it hasnt changed anything... Possibly it's something different.



Snooble
Link to comment
Share on other sites

Fantastic. Thank you. Thats what i needed to know. So... ifastnet.com... isn't.... friendly... God. All these adjustments for... Nothing.

Thats the best news ever. and the only outcome i could of expected. Well... Solved it is. Thank you to kenrbnsn and the others for there help! :)

God.. i can sleep now!

zzzzzzzzzzz

Snooble
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.