Jump to content

Problem defining form action


monkeybidz

Recommended Posts

I tried setting the form action as:

 

<?=$postar;?>

<?=$postar?>

<? print $postar;?>

 

The form is to post to itself depending on the set mode. Here is the code.

<?
if($mode=="recall"){
$postar="sell.php?mode=recall";
}else{
$postar="sell.php";
}
?>
       <form action="<? echo $postar; ?>" method="post" name="zipcodestuff" target="_self" id="zipcodestuff">

 

I need it to post $postar in form action.

Link to comment
https://forums.phpfreaks.com/topic/77692-problem-defining-form-action/
Share on other sites

try this:

 

<?php

$mode = $_GET['mode'];

if ($mode == "recall") {
$postar="sell.php?mode=recall";
}
else {
$postar="sell.php";
}
?>
        <form action="<?php echo "$postar"; ?>" method="post" name="zipcodestuff" target="_self" id="zipcodestuff">

 

you will missing you double quoates

That does the same thing I had, only problem I am having, is that the form is multipart and when the first part is submitted, it is to post to itself and keep other variable from the second form which are pre defined since this page is a page that is bieng edited by a user. When i submit the form, all other vars are lost.

try this monkeybidz:

 

<?php
session_start();

if ($mode == "recall") {
$postar="". $_SERVER['PHP_SELF'] ."?mode=recall";
}
else {
$postar="". $_SERVER['PHP_SELF'] ."";
}

$_SESSION['mymode']="$postar";

?>
<html>
<head>
        
<title>Untitled</title>

</head>
<body>

<form name="zipcodestuff" action="<?php echo $_SESSION['mymode']; ?>" method="post">
<input type="submit">
</form>

</body>
</html>

 

I think this should do what you want it to do.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.