Jump to content

Variable passing


GrayRyder

Recommended Posts

You are mixing POST and GET. If you want to pass the variables in the URL use GET. You need to output the variables to the form to a field not in the URL.  As Barand said it should be in a hidden field if you don't want it displayed on the page.

Edited by gw1500se
Link to comment
Share on other sites

After further investigation I don’t need to invoke an action.php file.  I think, the comparison  can be performed in sceureEmail form  used by the user.  It still would nice to know if a variable can be passed to the forms action file.

Thank for your help in forming my understanding.

Link to comment
Share on other sites

Bad news, my last post work around did not work.
Let me explain what going on.   The user runs securteEmail.php  which is a form that sends an email with a random 4 digit code to the users email.  The user reads his email and inserts the code sent to his email in the secureEmail.php form, which invokes the action file SCAction.php.  The code in the form is successfully sent and read by SCAction.php. Tthe problem, the original code  has to be compared to the email code.  There for  has to be sent to SCAction.php.   The email code entered in the form is read from the form by SCaction.php.   I need the action code to fetch the users email code that is entered.

**** The secureEmail.php code: ****

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>Seurity Email Service</title></head>
<body>
<?php
$SC2 =  $input[$rand_keys[0]];
echo "SC code sent = ", $SC2, "<br>";
echo "After the SC code is sent to the Email, we are at the Form  <br>";
?>
<FORM METHOD="POST" ACTION="SCAction.php/?cmd= set&var1=$SC2">
<H2>Security Code Service</H2>
<p>Enter the Security Code from the recipient's Email & Submit </p>
<?php $Scode = substr("$Scode", 0, -4); ?>

<INPUT NAME="Scode", value = <?php echo  (""); ?>  >
<!-- <input type="submit" /> -->
<?php
$Scode = $_POST['Scode'];
Echo "Scode = $Scode <br>";
echo "<br>Security code (SC = $SC)";
echo " sent to ", $to_address, "<br>";
?>
</FORM>
</body>
</html>

****The SCAction.php code:****

<?php

if(isset($_GET['$SC'])){
 $SC=stripslashes($_GET['$SC']);
}
Echo  "SC = $SC <br>";

$Scode = $_POST['Scode'];
Echo "Scode = $Scode <br>";
   if ($SC === $Scode)  {
   echo "Success, this is the Security Code from the Email : {$_POST['Scode']}<br />";  
} else {
 echo "<br>Illegal Security Code from the Email <br>";
}
?>

Link to comment
Share on other sites

12 minutes ago, GrayRyder said:

There for  has to be sent to SCAction.php.

Did you see Barand's response about PHP variables needing to be outputted in PHP? Try changing this

<FORM METHOD="POST" ACTION="SCAction.php/?cmd= set&var1=$SC2">

To this

<FORM METHOD="POST" ACTION="SCAction.php/?cmd= set&var1=<?=$SC2?>">

Note the $SC2 variable at the end.

Link to comment
Share on other sites

Ok - you send the user a form with a value in it.  Is there really a form involved there?  Sounds like you the user simply runs a script to get the code emailed to them, although I don't know how he provides the email address.  Is that in this first form?

Ok - the user gets an email with a code.  is there already a new form on screen for him to switch back to from his email client and type in the just-received code?  If so then he simply submits that 2nd form and your server has everything it needs.  Either with a hidden field in that second form, or better yet, saved in the session by the first script that created the code.

Does that make sense to you?

Edited by ginerjm
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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