Page 1 of 1

PHP, Hidden Fields and Strings

Posted: Tue Oct 13, 2009 11:41 am
by wolfnipplechips
Hi there,

I'm passing values from one form to another using php. However, although the information is transferred, in some cases the text is stripped down to the first word only. I'm a bit of an amatuer and imagine it's an easy solution and would welcome some assistance.

These are the hidden fields bieng transferred. At this stage the information displays fine...

Code: Select all

<?php
include("frontend_scripts/connect_course.php"); 
$eventNumber=$_GET['eventNumber'];
$result = mysql_query("select * from events WHERE eventNumber='$eventNumber' ");
 
while($r=mysql_fetch_array($result))
{   
 
   $eventName=$r['eventName'];
   $eventLocation=$r['eventLocation'];
   $eventDate=$r['eventDate'];
      $eventCity=$r['eventCity'];
      
 
echo '<table width="500" border="0" align="center" cellpadding="5" cellspacing="0" class="underline">
<tr>
  <td width="184" height="18" valign="top"><span class="bodybold">'.$r["eventName"].' </span>
    <input type="hidden" value='.$r["eventName"].'  name="title" />
    <input type="hidden" value='.$r["eventLocation"].'  name="location" />
    <input type="hidden" value='.$r["eventCity"].'  name="city" />
    <input type="hidden" value='.$r["eventDate"].'  name="cdate" />
  <td width="85" valign="top"><div align="center"><span class="bodytext">'.$r["eventLocation"].'</span>
    
  </div>
  <td width="85" valign="top"><div align="center"><span class="bodytext">'.$r["eventCity"].'</span>  
  </div>
  <td width="121" valign="top"><div align="right"><span class="bodytext"></span>  
      <span class="bodytext">'.$r["eventDate"].'</span>
    
  </div>
  </table>';
}
?>

I then use the following to preview the information being submitted...

Code: Select all

   <?php
 
 
echo '<input type="hidden" value='.$_REQUEST["title"].' name="title" />
<input type="hidden" value='.$_REQUEST["location"].' name="location" />
<input type="hidden" value='.$_REQUEST["city"].' name="city" />
<input type="hidden" value='.$_REQUEST["cdate"].' name="cdate" />
<input type="hidden" value='.$_REQUEST["name"].' name="name" />
<input type="hidden" value='.$_REQUEST["company"].' name="company" />
<input type="hidden" value='.$_REQUEST["email"].' name="email" />
<input type="hidden" value='.$_REQUEST["telephone"].' name="telephone" />
<input type="hidden" value='.$_REQUEST["address"].' name="address" />
<input type="hidden" value='.$_REQUEST["people"].' name="people" />
<input type="hidden" value='.$_REQUEST["questions"].' name="questions" />';
 
?>

Code: Select all

<?
$courseTitle=$_REQUEST["title"];
$courseLocation=$_REQUEST['location'];
$courseCity=$_REQUEST['city'];
$courseDate=$_REQUEST['cdate'];
$name=$_REQUEST['name'];
$company=$_REQUEST['company'];
$email=$_REQUEST['email'];
$telephone=$_REQUEST['telephone'];
$address=$_REQUEST['address'];
$people=$_REQUEST['people'];
$questions=$_REQUEST['questions'];
 
  echo "<span class='titles'>Course Title:$courseTitle<span><br>
  <span class='bodybold'>Course Location:</span><span class='bodytext'>$courseLocation</span><br>
  <span class='bodybold'>Course City:</span><span class='bodytext'>$courseCity</span><br>
  <span class='bodybold'>Course Date:</span><span class='bodytext'>$courseDate</span><br><br>
  <span class='bodybold'>Your Name:</span><span class='bodytext'>$name</span><br>
  <span class='bodybold'>Company Name:</span><span class='bodytext'>$company</span><br>
    <span class='bodybold'>Your Email Address:</span><span class='bodytext'>$email</span><br>
  <span class='bodybold'>Your Telephone Number:</span><span class='bodytext'>$telephone</span><br>
  <span class='bodybold'>Your Address:</span><span class='bodytext'>$address</span><br>
  <span class='bodybold'>Number of People Attending:</span><span class='bodytext'>$people</span><br>
  <span class='bodybold'>Your Questions:</span><span class='bodytext'>$questions</span>"; 
  
?>


Thanks in advance!

Re: PHP, Hidden Fields and Strings

Posted: Tue Oct 13, 2009 11:44 am
by jackpf
So what part doesn't work?

Also, what's displayed in the source of the page?

And aaaalso, you shouldn't really use _REQUEST unless the source of the data is ambiguous.

Re: PHP, Hidden Fields and Strings

Posted: Tue Oct 13, 2009 11:51 am
by wolfnipplechips
I assume the problem is with the '.$r["eventName"].' part.

For example, when the information is first displaed it may read 'Master VHDL Effectively'. However, when the information is transferred to the next page it will read 'Master'. EVerything accept the first word is being stripped off.

Re: PHP, Hidden Fields and Strings

Posted: Tue Oct 13, 2009 11:55 am
by jackpf
Also, what's displayed in the source of the page?
;)

Re: PHP, Hidden Fields and Strings

Posted: Tue Oct 13, 2009 12:26 pm
by wolfnipplechips
Here is the source for the first form...

Code: Select all

<form action="preview_registration.php" method="post" name="form" onsubmit="MM_validateForm('name','','R','company','','R','email','','RisEmail','telephone','','R','address','','R');return document.MM_returnValue"> 
        <p class="body"><br />
          <span class="orangetitle">Course Details...</span><span class="titles"><br />
          <br />
          </span> 
          <table width="500" border="0" align="center" cellpadding="5" cellspacing="0" class="underline">
<tr>
  <td width="184" height="18" valign="top"><span class="bodybold">Master VHDL Effectively </span>
    <input type="hidden" value=Master VHDL Effectively  name="title" />
    <input type="hidden" value=France  name="location" />
    <input type="hidden" value=Paris  name="city" />
    <input type="hidden" value=12-Oct-2009  name="cdate" />
  <td width="85" valign="top"><div align="center"><span class="bodytext">France</span>
    
  </div>
  <td width="85" valign="top"><div align="center"><span class="bodytext">Paris</span>  
  </div>
  <td width="121" valign="top"><div align="right"><span class="bodytext"></span>  
      <span class="bodytext">12-Oct-2009</span>
    
  </div>
  </table>        <br />
          <span class="orangetitle">Your Details...</span><span class="titles"><br />
          <br />
          </span><span class="smalltitle">(* Must be completed)</span><br />
          <br />
        </p>
        <span class="bodybold">Name*</span><span class="bodyBold"><br>
        <input name="name" id="name" SIZE="30">
        <br />
        </span>
      <p>
        <span class="bodyBold"><br />
        <span class="bodybold">Company*</span><br />
        <input name="company" id="company" size="30" />
        <br />
        <br />
        <span class="bodybold">E-mail*</span><br />
        <input name="email"   size="30" />
        <br />
        <br />
        <span class="bodytextbold">Phone*</span><br />
        <input name="telephone" size="30" maxlength="15" onchange="checkPhone(this)" />
        <br />
        <br />
        <span class="bodytextbold">Address*</span><br />
        </span><span class="bodytext">Please tell us your location to allo us to pass your request to your local office</span><span class="bodyBold"><br /> 
        <br />
        <textarea name="address" cols="40" rows="4"></textarea>
        <br />
        <br />
      </span><span class="bodytextbold">Number of people interested in this class: </span><span class="bodyBold"><br>
        <input name="people" id="people" SIZE="30">         
        </span>
      
      <p>
        <span class="bodyBold"><br />
        </span><span class="bodytextbold">Any questions?: </span><span class="bodyBold"><br>
        <TEXTAREA name=questions cols=40 rows=4 id="questions"></TEXTAREA>
      </span>        <br />
      <p>
         <input type="submit" name="Submit32" value="Preview and Register" onClick="MM_validateForm('name','','R','address','','R','places','','RisNum','delegates','','R','company','','R','telephone','','R','email','','RisEmail','contact','','R');return document.MM_returnValue">
         <input type="reset" name="Submit222" value="Reset">
         <br />
         <br />
    </form>

Here is the second source code...

Code: Select all

<form id="form2" name="form2" method="post" action="forms/process_interest.php">
    <span class="body">
    <input type="hidden" value=Master name="title" />
<input type="hidden" value=France name="location" />
<input type="hidden" value=Paris name="city" />
<input type="hidden" value=12-Oct-2009 name="cdate" />
<input type="hidden" value=Phil Wimbledon name="name" />
<input type="hidden" value=Ash Tree Design name="company" />
<input type="hidden" value=phil@ashtreedesign.net name="email" />
<input type="hidden" value=4353454 name="telephone" />
<input type="hidden" value=test name="address" />
<input type="hidden" value=3 name="people" />
<input type="hidden" value=test name="questions" />    </span>
    <span class='titles'>Course Title:Master<span><br>
  <span class='bodybold'>Course Location:</span><span class='bodytext'>France</span><br>
  <span class='bodybold'>Course City:</span><span class='bodytext'>Paris</span><br>
  <span class='bodybold'>Course Date:</span><span class='bodytext'>12-Oct-2009</span><br><br>
  <span class='bodybold'>Your Name:</span><span class='bodytext'></span><br>
  <span class='bodybold'>Company Name:</span><span class='bodytext'></span><br>
    <span class='bodybold'>Your Email Address:</span><span class='bodytext'></span><br>
  <span class='bodybold'>Your Telephone Number:</span><span class='bodytext'>4353454</span><br>
  <span class='bodybold'>Your Address:</span><span class='bodytext'>test</span><br>
  <span class='bodybold'>Number of People Attending:</span><span class='bodytext'>3</span><br>
  <span class='bodybold'>Your Questions:</span><span class='bodytext'>test</span>    <br />
    <br />
      <a href="#" onClick="history.go(-1)"></a> 
<input type=button value="Make Changes" onClick="history.go(-1)"> 
<input type="submit" name="Submit2" value="Register My Details" />
  </form>

Re: PHP, Hidden Fields and Strings

Posted: Wed Oct 14, 2009 3:27 am
by wolfnipplechips
Anybody else with any suggestions?

Re: PHP, Hidden Fields and Strings

Posted: Wed Oct 14, 2009 5:33 am
by jackpf
wolfnipplechips wrote:Anybody else with any suggestions?
Chill out...I have to sleep sometimes you know.

You need quotes round your value attribute.

Re: PHP, Hidden Fields and Strings

Posted: Wed Oct 14, 2009 5:50 am
by wolfnipplechips
Thanks for the reply - I'm perfectly chilled. Not sure what you meant by that, I was just bumping the question up to see if anybody else had any input.

I can see that there aren't any quotes around the value attribute. My problem is - how do I acheive this with the php.

<input type="hidden" value='.$r["eventName"].' name="title" />

Putting double quotes around .$r["eventName"]. doesn't work.

Re: PHP, Hidden Fields and Strings

Posted: Wed Oct 14, 2009 6:56 am
by jackpf
No, I mean like this:

Code: Select all

<input type="hidden" value="'.$r['eventName'].'" name="title" />

Re: PHP, Hidden Fields and Strings

Posted: Wed Oct 14, 2009 7:53 am
by wolfnipplechips
Thanks jack,

I appreciate the help.

Re: PHP, Hidden Fields and Strings

Posted: Wed Oct 14, 2009 11:59 am
by jackpf
Cool.

Yeah, sorry for being a bit "touchy" earlier. Not having the best of days tbh.