Jump to content

Recommended Posts

Posted

Hello,

I am just writing a pw app. After successful login the program shall switch to a form with address data, passing an id to the script (which is a pw template).

How can I pass the id by POST to the address form?

To this purpose I included the following script:

<form name="myform" id="myform" method="post" action="../adressdaten">
<input type="hidden" name="adresse_id" id="adresse_id" value="<?php echo $adresse_id; ?>"/>
</form>
<script type="text/javascript">
    document.getElementById('myform').submit();
</script>

 

..the problem is that that the form is properly displayed, but the id got lost.

it is neither in $_POST nor in $input->post->adresse_id.

Any idea about how to pass the id?

 

Posted

Your form's action value does not look right:

<form name="myform" id="myform" method="post" action="../adressdaten">

What is adressdaten? 

Posted
4 minutes ago, szabesz said:

Hi,

Something like this?

you mean to pass the id as url parameter? I want to avoid this, because the user can manipulate the id and might have access to data of other users.

 

 

Posted
2 minutes ago, kongondo said:

Your form's action value does not look right:


<form name="myform" id="myform" method="post" action="../adressdaten">

What is adressdaten? 

adressdaten is the part of the url which you define when creating the page.

But THIS works as the form is properly displayed.

Posted (edited)

I was not referring to the display :) since you clearly stated the form displays. The issue is the other side, the server-side. I have never tried it, but I am not sure you can post to a relative URL like that. What is the server response (dev tools) after you post? What happens if you post to the full URL instead? i.e. /something/adressdaten/

Edited by kongondo
Posted
9 minutes ago, kongondo said:

I was not referring to the display :) since you clearly stated the form displays. The issue is the other side, the server-side. I have never tried it, but I am not sure you can post to a relative URL like that. What is the server response (dev tools) after you post? What happens if you post to the full URL instead? i.e. /something/adressdaten/

When I use the full URL, it works. Even the adresse_id is being passed but only when it is hardcoded in the above script.

When it is inserted with 

<?php echo $adresse_id; ?>

..it still gets lost :-(

Posted

Well that's strange. Hard to tell what's happening without seeing the whole context. Just to confirm, when the form is displayed, is the value of $adresse_id correctly output? 

Posted
39 minutes ago, kongondo said:

Well that's strange. Hard to tell what's happening without seeing the whole context. Just to confirm, when the form is displayed, is the value of $adresse_id correctly output? 

It is being displayed when it is hardcoded.

The above script is included that way: 

        $adresse_id = 123;
        include('./callAdresse.php');

Posted (edited)

So there's your problem then; $adresse_id is not being passed to callAdresse.php, for some reason. I've tested and it works just fine in my case.  

Edit

Not sure where to go from here. Do you have a typo somewhere maybe? Debug errors?

Edited by kongondo
more thoughts
Posted
1 hour ago, kongondo said:

So there's your problem then; $adresse_id is not being passed to callAdresse.php, for some reason. I've tested and it works just fine in my case.  

Edit

Not sure where to go from here. Do you have a typo somewhere maybe? Debug errors?

 

1 hour ago, kongondo said:

So there's your problem then; $adresse_id is not being passed to callAdresse.php, for some reason. I've tested and it works just fine in my case.  

Edit

Not sure where to go from here. Do you have a typo somewhere maybe? Debug errors?

Now it works. The cause of the error was probably a missing semicolon after the echo command and the incorrect page was cached. Therefore the

adresse_id was not displayed even after the patch.

Posted
19 minutes ago, kongondo said:

I assume then that you did not have a debugger on then? :). Would have saved you some headache. 

I set $config->debug = true, but the missing semicolon did not cause an error message, though..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...