Saving data to database
-
Hello. I’ve been at this for 4 hours or so. I’ve made good progress, except for this one part.
The idea of this is to allow my members to type in a text input of let’s say promo, then if the word is correct it will create a random key and send it to a row under the table of wp_users.
Here’s my Code.<?php // values for answer trial = input answer = answer $trial = $_POST["promokey"]; $answer = "membersonly"; if( $trial == $answer) { // makes code if correct function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 225); //how long the code is } mt_srand(make_seed()); $promocode = mt_rand(); //promocode is code value //sends promocode to database wp_insert_user( array ('ID' => $user_id, 'promo_code' => $promocode) ) ; }else{ <form action="https://mysite.come/promo" method="post"> Promo Code: <input type="text" name="promokey" /> <input type="submit" /> </form> <?php } ?>
I just cant seem to make the promocode enter into the database under wp_users -> ID -> promocode.
Any Ideas?
Thank you!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Saving data to database’ is closed to new replies.