Jump to content

Recommended Posts

Dave did you even read any of the above?? or are you just forcing us to read your stuff and reply?

Read the stuff below!

 

Well just keep in mind random is not unique how unlikely a match may sound. (a date+time is unique depending on how many requests per time unit)

Maybe make a little hello world php script to test if there is any php.

just call it helloworld and place the following.

 

<?php //don't us short tag like <?
$string = 'hello world!'; //assign a variable;
echo $string;
?>

 

1) So to repeat RANDOM is NOT unique!!

2) DON'T USE SHORT TAGS (sorry but it seems by only using the capslock it makes this true :'( )

3) have a look at this: http://php.net/manual/en/function.rand.php (there is are parameters to limit the result, easiest with losing 1 million possibilities is

$random_is_not_unique = rand(100000,999999); //a random NON unique number
echo $random_is_not_unique; // echo random.

Hi

 

Sorry if I am being a bit thick here but but surely this:

 

<?php

srand ((double) microtime( )*1000000);

$random_number = rand( );

?>

 

does use the proper tags. Are you saying there should also be a <?php tag INSIDE the field line :

"intInstID" value = "<?php= $random_number; ?>">  here?

 

Thanks

 

Dave

Ok keep that ('dont use shorttags in your mind in other words always use <?php to start and ?> to end not <? to start ')

Now back to your app:

What you can do which is closest to unique.

 

1) we take time by using time();  only show last 6 digits since it will return a 9 digit value and we want 6

$time_value = time(); // get time
echo $time_value; // just to show its 9 digits  you can leave this out, but to see the idea.
$my_final_value = substr($time_value,-6); //assign a new var  only the last 6 digits with substr (check: http://www.php.net/manual/en/function.substr.php

 

You now have a nice value that increases every second so in a way it's unique. (unless multiple (simultaneous requests))

 

The value is stored in $my_final_value. to echo it in HTML or where ever you want echo it.

like:

 

<?php //Open and DON'T use short tags!!

echo $my_final_value; // don't forget semicolon

?>

 

So in a html form you can do this:

 

<!--- make sure this is between the body tags ( <body>  </body> ) -->
<form action="actionpage.html" method="post">
<input type="text" name="coolnumber" value="<?php echo $my_final_value; ?>" readonly="readonly" />
</form>


You could also use a hidden field, but that's up to you. hidden only means visually hidden

Hi

 

Sorry if I am being a bit thick here but but surely this:

 

<?php

srand ((double) microtime( )*1000000);

$random_number = rand( );

?>

 

does use the proper tags. Are you saying there should also be a <?php tag INSIDE the field line :

"intInstID" value = "<?php= $random_number; ?>">  here?

 

Thanks

 

Dave

 

just to clear things up a bit more.

 

You either use 1 a  .php file or 2 a .html file

#1 in php you can echo a form like:

with concatenating dots.    .$var.

<?php
echo '<form action="#" method="post">
<input type="text" name="monkeys" value="'.$variable.'" /> 
</form>';
?>

 

#2 in HTML you use <?php  ?> inside the fields.

Like:

<html>
<head><title></title></head>
   <body>
      <form action="#" method="post">
          <input type="text" name="monkeys" value="<?php $variable ?>" /> 
      </form>
   </body
</html>

 

 

Hi,

 

OK I hear what you are saying and thank you very much for the snippets, but leaving aside the uniqueness for a second why doesn't this work:

 

<?php

srand ((double) microtime( )*1000000);

$random_number = rand( );

?>

 

<form action = "https://secure.metacharge.com/mcpe/purser" method = "post">

    <input type = "hidden" name = "intTestMode" value = "1">

    <input type = "hidden" name = "intInstID" value = "<?php= $random_number; ?>">

    <input type = "hidden" name = "strCartID" value = "YourOrderId/userId/987654321">

    <input type = "hidden" name = "fltAmount" value = "29.99">

    <input type = "hidden" name = "strCurrency" value = "GBP">

    <input type = "hidden" name = "strDesc" value = "description of purchase">

    <input type = "submit" value = "Make Payment">

</form >

 

This :

<?php= $random_number; ?>

appears in the form field. See http://chiswickrestaurants.com/buynow.html

Is it because the server  does not in fact support PHP despite what they tell me?

 

Cheers

 

Dave

Hi,

 

OK I hear what you are saying and thank you very much for the snippets, but leaving aside the uniqueness for a second why doesn't this work:

 

<?php

srand ((double) microtime( )*1000000);

$random_number = rand( );

?>

 

<form action = "https://secure.metacharge.com/mcpe/purser" method = "post">

    <input type = "hidden" name = "intTestMode" value = "1">

    <input type = "hidden" name = "intInstID" value = "<?php= $random_number; ?>">

    <input type = "hidden" name = "strCartID" value = "YourOrderId/userId/987654321">

    <input type = "hidden" name = "fltAmount" value = "29.99">

    <input type = "hidden" name = "strCurrency" value = "GBP">

    <input type = "hidden" name = "strDesc" value = "description of purchase">

    <input type = "submit" value = "Make Payment">

</form >

 

This :

<?php= $random_number; ?>

appears in the form field. See http://chiswickrestaurants.com/buynow.html

Is it because the server  does not in fact support PHP despite what they tell me?

 

Cheers

 

Dave

 

No its probbaly because your using <?php  ?> inside <?php ?>

 

Look carefully at my examples.

try the concatenating dots

because i am in a good mood here you are :)

save the stuff below as any_name_youlike.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>monkeys</title>
    </head>
    <body>
        <?php
        $time_value = time(); // get time
        echo $time_value.'<br />'; // just to show its 9 digits  you can leave this out, but to see the idea.
        $my_final_value = substr($time_value,-6); //assign a new var  only the last 6 digits with substr (check: http://www.php.net/manual/en/function.substr.php
        echo $my_final_value.'<br />'; // for the sake of learning
        ?>

       <form action = "https://secure.metacharge.com/mcpe/purser" method = "post">
             <input type = "hidden" name = "intTestMode" value = "1" />
             <input type = "hidden" name = "intInstID" value = "<?php echo $my_final_value; ?>" />
             <input type = "hidden" name = "strCartID" value = "YourOrderId/userId/987654321" />
             <input type = "hidden" name = "fltAmount" value = "29.99" />
             <input type = "hidden" name = "strCurrency" value = "GBP" />
             <input type = "hidden" name = "strDesc" value = "description of purchase" />
             <input type = "submit" name="submit" value = "Make Payment" />
       </form >
    </body>
</html>

 

btw you cant do this  <?php= $random ?>  its should be <?php echo $random; ?>

 

Just a few things.

1)Read the manual on how to use concatenating dots / how to echo variables (read more in general: http://www.w3schools.com/php/php_syntax.asp)

2) I saw your website, for future websites, use an external stylesheet I saw loads of redundant inline style CSS (dont use inline css) It will save you crap loads of time which is needed to hang out with friends ::)

3) decide whether to echo the complete form (so inside php) or insert a small part of php inside the form

 

-edit: i added a semicolon i missed apparently so you can make that a fourth note: end lines with a semicolon.

-edit2: don't rely on the hidden field values (they can be changed) or you will be broke just like the pizza man next door. (sessions with database values are far more reliable)

No your not stupid there was a > missing in <br /> 

But the code as it is now works just do it again ::) and install xampp (test local takes you 5 minutes to install)\

see attachment that is working (but so is the code above)

I can recommend to use Netbeans to

 

[attachment deleted by admin]

.PHP!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

can you maybe make a phpfile named:

just_to_remind_myself.php so not just_to_remind_myself.html ( but    .php)

 

with the following content:

 

<?php

echo 'read the manual';

?>

 

if that doesn't clear things up I don't know what to do.

Anyways i am off spended an hour on this.

Goood luck an keep in mind hidden fields can't be relied on!

Thanks very much for your help Fortnox, you've been brilliant.

 

For the life of me I can't get it to work.  I have embedded this code in an html page but it should still work I reckon.

 

I dunno.... I don't even understand your last post, why would that code help?

 

Oh well - better start on a plan be or use the javascript and take a punt that people have it enabled it.

 

Cheers

 

Dave

I am not gonna answer that since it would be more that nice to try it and see it for your self.

Just skip your site for a brief second and make a .php file (SO NOT A .HTML file)

if it's a .html file it wont work. (oh could it maybe be that my page is named page9.html and that facks everything up?? a little voice says: YES!)

 

Just run my code I made. Don't implement or do anything with it just run it as is. (as a .php file!!)

Oops now I gave the answer i think 4 times. :rtfm: :'( :'( :'(

I am not gonna answer that since it would be more that nice to try it and see it for your self.

Just skip your site for a brief second and make a .php file (SO NOT A .HTML file)

if it's a .html file it wont work. (oh could it maybe be that my page is named page9.html and that facks everything up?? a little voice says: YES!)

 

Just run my code I made. Don't implement or do anything with it just run it as is. (as a .php file!!)

Oops now I gave the answer i think 4 times. :rtfm: :'( :'( :'(

 

I've told him this several times already. :(

 

By default, HTML files will not be parsed by PHP.

IT WORKS, IT WORKS, IT WORKS

 

Thank you thank you thank you - I feel a right idiot not understanding that you needed me to change the .html extension to .php.

 

It works a treat now - thank you everyone - especially Fortnox - for your patience and help

 

I really appreciate

 

Thank you again

 

Dave

 

PS I will read the tutorial... :D

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.