close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

I cannot get this to work

Thread began 5/24/2012 5:29 pm by akstudio | Last modified 6/07/2012 12:51 pm by akstudio | 4108 views | 24 replies |

akstudio

I cannot get this to work

I have followed exactly as described.
cookies_toolkit_gsg.pdf

Well... not EXACTLY, as my form differs.

Maybe what I am trying to do can't be done, I'll describe it.

I have 2 pages. Page 1, populated with dates from a table.
Page 2 has a form.

I want a person to choose a date on page one, and on page 2 have it auto filled into the form.


Page one has a form, and a hidden element within it. This hidden element, after following the pdf, looks like this:

<input name="ntu_date" type="hidden" id="ntu_date" value="<?php echo((isset($_POST["ntu_date"]))?$_POST["ntu_date"]:"") ?>" />

Page 2 has a textfiled that looks like this:

<input type="text" name="ntu_date" id="ntu_date" value="<?php echo((isset($_COOKIE["ntu_date"]))?$_COOKIE["ntu_date"]:"") ?>" size="32" />

Is there another tutorial I can follow or one of those video tutorials available? I have been trying to pass a simple variable to this form all day long with no luck. I thought I have tried every combination I could, but I must be mission one.... the one to make it work.

thanks

Sign in to reply to this post

akstudio

This is a nightmare at this point, I've spent 16 hours straight trying to figure out how to pass form information.

I'm beginning to think that what I am trying to do, or rather, the approach I am taking to achieve this is completely wrong.

I have on page 1, a repeat region. Inside this repeat region, I have a form and inside it I am pulling dates from a table. It looks like this: <?php echo $row_ntu['ntu_date']; ?>

This form also contain the following:
<input name="ntu_date" type="hidden" id="ntu_date" value="<?php echo $row_ntu['ntu_date']; ?>" />

I want to take THAT specific date, and pass it to a second form, on page 2... to auto populate a field. Better yet, I would also like to display this date on the page as well. If I can't achieve the later, I'll settle for auto populating a form field.

Now, I have gone over the pdf dozens of times, I've spent the evening looking through other documentation, researched about the internet... I've come across working examples where $_REQUEST is used, etc.

I just cannot get it to work on my page. I thought it would be easy to just store the output of $row_ntu['ntu_date']; into a cookie or session var and load it up on page 2.

What am I missing here?

Sign in to reply to this post

Ian S

What form action method are you using? POST or GET?

If you are posting then you will set the value of the form on the second page to $_POST['ntu_date']

If you are getting then you will set the value of the form on the second page to $_GET['ntu_date']

The other thing you could do, if you want to store the values for future use within a multi-page form is post the form to itself, store the form values in session variables and then redirect to the next page. Then you can call on the session values whenever you need to.

Cheers
Ian

Sign in to reply to this post

akstudio

Thanks, Ian.

I've just tried the server redirect and for whatever reason, nothing happens when ckicking on the form button.

// ------------------------- Here is my session var:
<?php
if (!session_id()) session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION["ntu_date"] = "".$row_ntu['ntu_date'] ."";
}
?>


// ------------------------- And here is the redirect:
<?php
if(($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)){
$WA_Redirect_URL = "ntu_form.php";
$WA_Redirect_KeepQS = true;
if ($WA_Redirect_URL != "") {
if ($WA_Redirect_KeepQS && $WA_Redirect_URL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "") {
$WA_Redirect_URL .= ((strpos($WA_Redirect_URL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_Redirect_URL);
}
}
?>

// ------------------------- And here is the form:
<form action="" method="post" name="ntu_form" id="ntu_form" onsubmit="WA_setFormCookie(WA_CookieObj,document.ntu_form,'WAFC_ntu_ntu_form', 30)">
<div class="ntubox_info">
<div class="ntu_cal"><img src="images/cal.gif" width="48" height="52" alt="" /></div>
<div class="ntu_register">
<input name="" type="button" value="Sign up" />
<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_ntu['ntu_date']; ?>" />
<br />

<!--<a href="#"><img src="images/signup.gif" alt="register" width="100" height="52" border="0" /></a>-->

</div>
<div class="ntu_title"><?php echo $row_ntu['ntu_title']; ?></div>
<div class="ntu_content"><?php echo $row_ntu['ntu_date']; ?> </div>
<div class="ntu_seats"> Seats Available: <span class="bold-red"><?php echo $row_ntu['seats_avail']; ?></span> </div>
<div class="clear"></div>
</div>
</form>



Any idea?

Sign in to reply to this post

Ian S

I can't see how your form is submitting.

Does it have a submit button?

Try changing:

<input name="" type="button" value="Sign up" />

to

<input name="" type="submit" value="Sign up" />

Cheers
Ian

Sign in to reply to this post

akstudio

ok I got the form to post to its self and redirect properly... on page 2 it seems as tho the session is only from the first record, regardless of which button I choose from the first page

Sign in to reply to this post

Ian S

So do you have a form that is repeated and the elements keep getting the same name etc?

I would think that you would need to give your form elements unique names (based on the ID of the record maybe)? If the elements have the same name then you will always get the information from the first one in the form.

Cheers
Ian

Sign in to reply to this post

akstudio

I have a form, in a repeat region.

Inside that form, I have a hidden field.
The value of that hidden field is: <?php echo $row_ntu['ntu_date']; ?>

This date is pulled from the DB

When the page is rendered in the browser, I look at the source code of the page and it does in fact, show different dates.

However, when I submit the form, and go onto the next page, the "session.ntu_date" is always the first record in the DB

I understand what your saying, by giving it a unique ID, but I am at a loss on how to approach this.... because, if in fact I need a specific identifier, I would imagine the result would always be the same, because it is in the repeat region.

Please advise.

thanks

Sign in to reply to this post

Jason ByrnesWebAssist

not enough detail.

what is the code to set the ntu_date session variable?

it would help to have a copy of the pages so we can see the code to get a better understanding of what you are doing.

Sign in to reply to this post

akstudio

files attached.

Basically, a visitor picks a date one page one, then a form field on page 2 is populated with said date.

That's all I'm really trying to pull off here.

Thanks

Attached Files
session.zip
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...