Jump to content

Recommended Posts

Thank you, jesirose and mattd8752

 

jesirose, i didn't understand the sessions, part, so I went with mattd8752's reply.

 

i can get it to work mattd8752, thank you very much.

 

is there a way to embed it into a specific spot on my html page?

 

thank you so much

 

tina

Jesirose

 

Can you please explain your process to me.

 

I understand the saving as php page, I need to understand, what you mean by processing the form on the same page and then the sessions part.

 

As i can' t seem to get the errors to list inside the html page by using the include statement.

 

Thank you,

 

Tina

very simple example:

 

form.php

<?php
   session_start();
   if($_SESSION['errorMsg']) {
      echo $_SESSION['errorMsg'];
      unset ($_SESSION['errorMsg']);
   }
?>

<form method = 'post' action='process.php'>
   Enter something   <input type = 'text' name = 'something'>
   <input type = 'submit' value = 'send'>
</form>

 

process.php

<?php
   session_start();
   if (!isset($_POST['something']) || trim($_POST['something']) == "") {
      $_SESSION['errorMsg'] = "please fill out field";
   } elseif (strlen($_POST['something']) > 10)) {
      $_SESSION['errorMsg'] = "something is too long. Please make it 10 or less chars";
   } 

   if ($_SESSION['errorMsg']) {
      header('Location: form.php'); exit();
   } else {
      // no errors, do whatever. 
   }
?>

 

Still a little bit unclear to me, probably because of never using sessions before.

 

below is what and how I am dealing with errors on the "process side of things, which is my register.php"

if(isset($_POST['Send'])){
$errors = array(); // Initialize error array.

if(empty($_POST['name'])) {
	$errors[] = 'You did not enter your Name.';

 

below is the scaled down version of my registration.php form which is really just html

<form action="register.php" method="post" target="_self">
                <tr>
                  <td height="20" colspan="3" align="left" valign="top"><input name="name" type="text" class="graytext1" id="name" size="60">      
                  <td height="20" align="left" valign="top"><input name="email" type="text" class="graytext1" id="email">
                <tr>
                  <td height="15" colspan="2" align="left" valign="bottom" class="graytext">Address
                  <td height="15" colspan="2" align="left" valign="bottom" class="graytext">Add'l Address
                <tr>
                  <td height="20" colspan="2" align="left" valign="top"><input name="address" type="text" class="graytext1" id="address" size="40">

 

this is the bottom of my register.php for the errors

} else {
	echo '<id="errors">Error!<p class="error">The following error(s) occurred:<br />';
	foreach ($errors as $msg) {
	echo " - $msg<br />\n";

 

if you could possibly let me know where things should go, that would probably make it clearer to me.

 

Thank you,

 

Tina

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.