Jump to content


Photo

php / html question


  • Please log in to reply
23 replies to this topic

#1 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 02:48 PM

Once again i am trying to do things that most don't do. I am trying to send a php variable from an html page imbedded in a check box value so that when it gets to the next page that is a php page it is read as a variable. Here is the code that i am trying so far.

On the HTML page

<input type="checkbox" name="checkbox5" value="'If no imiprovement in '.$Improve.' hours, you must be re-evaluated'"><input type="text" name="Improve" size="10">

An on the just a simple

echo $checkbox5;

on the php page.

This is what i get:

\'If no imiprovement in \'.$Improve.\' hours, you must be re-evaluated\'

dose anyone have any ideas?



#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 03:31 PM

What do you want? If you need to output a variable outside PHP, you should use this:

value="'If no imiprovement in '<?=$Improve?>' hours, you must be re-evaluated'"

Then, when retrieving it use stripslashes() to remove the backslashes that were added thanks to Magic Quotes:
[a href=\"http://www.php.net/stripslashes\" target=\"_blank\"]http://www.php.net/stripslashes[/a]
~ D Kuang

#3 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 04:00 PM

That is what i was thinking would work but i could not remember the stripslashes() command. However it did not seem to work. now i am getting.

'If no imiprovement in '' hours, you must be re-evaluated'


Would it be better if i was going from a php page to another php page?

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 04:09 PM

Actually it won't work if you are using a HTML file (with .html or .htm extension) because the PHP doesn't parse it.

You must at least rename the page to something.php

Or edit the .htaccess and make the PHP interpreter go through .html files too.
But this could cause a potential performance hit, so it's not quite recommended.
~ D Kuang

#5 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 04:18 PM

are you saying both pages need to be php or just the second page that is reading the variables?

I have tried it with both pages having a .php extension and also with the first page with the check box and text box as a html file and then going to a php file.

#6 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 04:28 PM

All the pages with PHP should have .php extension.

Also, if you have a html page that just outputs $Improve it won't work if it's not defined.

If $Improve comes from somewhere else, it should be correctly passed to the page that outputs it.

(I hope you can understand what I'm saying).
~ D Kuang

#7 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 04:38 PM

yeah that makes sense I know that $Improve is being passed properly because i can echo $Improve and get what I am looking for. I am just trying to imbed that into the checkbox so that all i have to do is echo the checkbox value and get both.

I was asking if there is a php function that allows you to do what I am trying to do. Because if there is I can make the form page a php page because right now it is just a html page.

the problem seems to be when the information is submitted form the html form page to the php page the <?=$Improve?> is not carried over.

dose that make sense at all?

#8 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 04:52 PM

Yes it does.

Try to add this bit of code in the same page as where you are using <?=$Improve?>:

<?php var_dump($Improve); ?>

And see what it gives to you.
~ D Kuang

#9 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 04:57 PM

I replaced <?=$Improve?> with <?php var_dump($Improve); ?> on the html form page. and when I hit submit to get to the php page where I am trying to recall these variables there was still nothing where <?php var_dump($Improve); ?> was.


#10 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 05:00 PM

Most likely, the page is not being parsed by PHP.

Are you sure it's in PHP extension?
~ D Kuang

#11 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 05:03 PM

Which page are you talking about there are 2 pages involve here.

A form page that has a html extension.

And a display page that has a php extension.



#12 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 05:08 PM

As said before, any page containing the smallest bit of PHP MUST have php extension.

Including the form page.
~ D Kuang

#13 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 05:17 PM

So you are saying that both the form and the display page need to have a php extension. Okay I under stand that. The problem with that is that because the variable $Improve is established on the same page as the checkbox. there is nothing for the code <?=$Improve?> that is in the checkbox value to pull in. so it just puts a blank space in. What I am trying to do is put something in the checkbox value that will retrieve that variable $Improve on the next page after it has been established.


dose that make sense.
And I don't know if this is even posible.

#14 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 05:48 PM

I am not understanding from where $Improve comes from.
If it's created in the same page as it's output, that's fine.
If you want it to be passed, that's fine; it will be passed by the form.
In this case I'd recommend you to use:

<input type="checkbox" name="whatever" value="<?= $variable ?>">

But if you want to retrieve $Improve, which comes from another page, you must pass it properly; by POST, GET, COOKIES, SESSION or whatever you may want to use.
~ D Kuang

#15 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 05:58 PM

maybe it will help if i give you more of the code
Here is the relevant code from the form page which is a .php page

<html>
    <head>
        <title>Discharge</title>
        <form method=post action="../Print.php">
    </head>

<body>
<table width="800" border="1" cellspacing="0" cellpadding="0">
<tr>
    <td width="20"><input type="checkbox" name="checkbox5" value="'If no imiprovement in '<?=$Improve?>' hours, you must be re-evaluated in the Emergency Room or by your primary care doctor.'">
       </td>
    <td>If no imiprovement in <input type="text" name="Improve" size="10"> hours, you must be re-evaluated.</td>
</tr>
</table>
<input type="submit" name="Print" value="Print">

This is what i have on the Print.php page

<?php
echo $checkbox5;
?>

And this is what i get on the Print.php page.

'If no imiprovement in '' hours, you must be re-evaluated.'

do you see what i am trying to do? If it is not possible just let me know and I will try to come up with another way of doing it.



#16 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 06:03 PM

Do you want people to be able to enter the hours?
In this case remove the checkbox:
    <td>If no imiprovement in <input type="text" name="Improve" size="10"> hours, you must be re-evaluated...</td>

Print.php

<?php
echo $_REQUEST['Improve'];
?>

500th post [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
~ D Kuang

#17 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 06:08 PM

The problem with that is that then only the hours that are typed into the text box are passed to the second page. And the reason that i am doing it this what is because depending on what happens earlier on the site the check box might be different.

Just tell me that what I am trying to do is impossible and I will give up.

#18 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 02 June 2006 - 06:12 PM

But people can't change the amount of hours in a checkbox, unless they mess with JavaScript.

What do you want to get, exactly?
~ D Kuang

#19 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 06:23 PM

lets see if i can explain.

On the form page there is a checkbox next to this text.
If no improvement in "Text field" hours, you must be re-evaluated.

there is a check box there because they may not always need to use this line.

when it is read on the print page I have a if statement that checks to see if the checkbox has been checked and if so I would like it to write if no improvement in "what ever they put in the text box on the previous page" hours, you must be re-evaluated.

And I need all that to be stored in variables from the form page.

So if there is a what to splice to variables together at a point that would work or something like that. I don't know I am running out of ideas.

let me know if any of my explanations don't make sense.

#20 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 02 June 2006 - 07:46 PM

If echo $checkbox5; returns $Improve.
is there something that I do to recall $Improve.
something like ${$checkbox5};




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users