Pages:
Author

Topic: PHP Coding question in regards to validat user input before passing it into mysq - page 2. (Read 354 times)

legendary
Activity: 2758
Merit: 6830
What exactly is missing?

You already know how to verify if the address is valid. If it is, insert it into the table (as you already know), if it doesn't, do something like this:

Code:
if (!valid) {
   $error = "Invalid address.";
}

// and maybe in the html
<**php if ($error) { echo $error; } **>

// i changed ? to ** since cloudflare was blocking the code with the real php tag

An working example:

Code:
<**php

if (isset($_POST["address"])) {
    $address = $_POST["address"];
    if (checkAddress($address) {
        addAddressToDb($address);
    } else {
        $error = "Invalid address.";
    }
} else {
    $error = "Please input an address.";
}

**>



    Add Address


    <**php if (isset($error)) { echo $error; } **>
    

        
        
    




// again, i changed ? to ** since cloudflare was blocking the code with the real php tag

And then, the addAddressToDb($address) function simply receives the address as a parameter and add it to the database with the INSERT sql command.

Or something like this.
sr. member
Activity: 709
Merit: 336
You need someone to develop your Web project ?
Hello,

I am able to provide you with the code you want.

I will not have time to do it today.

I will try to arrange to write the script tomorrow normally Wink
newbie
Activity: 22
Merit: 0
I have a small programm where i take in a users Bitcoin address as input and than insert it into mysql database.



user inputs bitcoin address and clicks submit button

which than validates the bitcoin address and if address is valid- he can click submit button and gets redirected to a different part of my site- and if address is valid it gets added to mysql database.

If input isn't valid - display an error message

Im using php for everything

I just dont know how to put this together into a working project

you find the code to my question here

https://pastebin.com/DpPgp2Xi

i wasnt able to post mysql code here in the forum
Pages:
Jump to: