Generete Unique Id and pass into text field - unique

I am new to php and would like some help on solving a problem I am having. I have a form that has 3 visible input fields, Name, Email address, phone number. Also it includes 3 hidden fields, one is a value set to 2500, the second is a currency, the third needs to be a unique ID. I need help on how to generate a unique id and pass the text/value into a input field in another form. Below is my code. I need the random id to be displayed on the input field merchantid. Thanks
<form action="https:urlthathastheform" method="post">
<input type="hidden" id="merchantid" name="merchantid" />
<input type="hidden" id="currency" name="currency" value="$" />
<label for="names">Names</label>
<input type="text" name="names" id="names" />
<label for="email_address">Email Address</label>
<input type="text" name="email_address" id="email_address" />
<label for="phone_number">Phone Number</label>
<input type="text" name="phone_number" id="phone_number" />
<label for="amount">Amount</label>
<input type="text" name="amount" value="2500" />
<input type="submit" name="submit" value="submit" />
</form>

php has a function to generate a unique id.
<input type="hidden" id="merchantid" name="merchantid" value="<?php echo uniqid();>"/>
Note, this id is based on the system clock. http://php.net/manual/en/function.uniqid.php

Related

why this pattern=”^re\-\d{6}$" not working properly in html

it's not giving me error message when I input different pattern, what did I do wrong ?
<label for="receipt">Receipt number *</label>
<input name="receipt" id="receipt"
placeholder="re-nnnnnn" required="required"
pattern="^re\-\d{6}$" />
It depends on what you want to achieve. For example, if your goal is re-123456, you should remove the first back-slash.
<form action="">
<label for="receipt">Receipt number *</label>
<input name="receipt" id="receipt" placeholder="re-nnnnnn" required="required" pattern="^re-\d{6}$" />
</form>

HTML Pattern for phone numbers

This is my first time writing a pattern for HTML phone numbers. I am based in Singapore. In my country phone numbers starts with 8 or 9 and has 9 digits.
This is my html pattern.
Can someone take look and let me know what went wrong?
I don't see any resources out there for including certain numbers only.
pattern: ([8|9]{1}[0-9]{8})
below is my full code
<h3>Sign Up</h3>
<label htmlFor="username" className="sr-only">Username: </label>
<input type="text"
name="username"
minLength= '5'
maxLength= '10'
onChange={onChange}
className="form-control"
placeholder="Enter Username" required />
<label htmlFor="password" className="sr-only">Password: </label>
<input type="password"
name="password"
minLength= '8'
pattern = "(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
title = "Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters"
onChange={onChange}
className="form-control"
placeholder="Enter Password" />
<label htmlFor="email" className="sr-only">Email: </label>
<input type="text"
name="email"
onChange={onChange}
pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,}$"
className="form-control"
placeholder="Email" required />
<label htmlFor="mobile" className="sr-only">Mobile Number: </label>
<input type="number"
name="mobile"
onChange={onChange}
className="form-control"
pattern="[8-9]{1}[0-9]{8}"
placeholder="Mobile Number" />
<button className="btn btn-lg btn-primary btn-block"
type="submit">Sign Up</button>
The answer is that pattern is not a valid attribute on input when type=number. Also the pipe character inside []'s doesn't mean "or". Either change the input type to another value, or use min/max.
<input type="text" inputmode="numeric"
name="mobile"
onChange={onChange}
className="form-control"
pattern="[89][0-9]{8}"
placeholder="Mobile Number" />
or
<input type="number"
name="mobile"
onChange={onChange}
className="form-control"
min=800000000
max=999999999
step=1
placeholder="Mobile Number" />
Phone number starting with 8-9 and remaing 9 digit with 0-9" required
<input type="text" class="form-control" readonly="readonly" value="" name="enquiry_mobile" placeholder="Enter mobile number *" pattern="[8-9]{1}[0-9]{8}">
If you expect that using pattern on input will prevent you from entering incorrect data base on that pattern, you're wrong.
You have to submit the form for the browser to validate. The first form bellow will submit, the second one will not.
<form>
<input value="891234567" type="tel" id="phone" name="phone" pattern="([89][0-9]{8})" />
<button>Submit</button>
</form>
<form>
<input value="121234567" type="tel" id="phone" name="phone" pattern="([89][0-9]{8})" />
<button>Submit</button>
</form>
Edit:
As #Robert McKee pointed in the comment below, the first pattern used on this answer is incorrect. Updated pattern to ([89][0-9]{8}).

Combine HTML inputs?

HTML form
I am trying to combine:
<input name="domain" id="domain" required="" type="hidden" value="domain.com">
<input name="username" id="username" required="" type="text">
to pass this combined information in the form as what is now:
<input name="user" id="user" required="" type="text">
Current code:
<input name="user" id="user" required="" type="text">
This requires the user to type both the domain and user name into the text box.
Example: domain.com\username
I would like to include the static domain “domain.com\” as hidden text to the input so they can just type the username.
Example: username
The code currently is:
<p>Username:</p>
<input name="user" id="user" required="" type="text">

How to send an html form with values filled

Basically i have a html form as string
<form class="form login_form" action="https://app.box.com/api/oauth2/authorize?response_type=code&redirect_uri=http://localhost:8080/&client_id=6n8aeye40bowhwz&state=V8eTbbtXbsV" method="post" name="login_form">
<ul class="container error_container basic_list basic_list_sm hidden"><li class="data plm warning ram pas man"><div class="media pvs"><div class="img icon"><div class="sprite_signup_login_icon_error"></div></div><div class="bd"></div></div></li></ul>
<div class="field_set login_fields fw center">
<div class="login_user_inputs"><label for="login" class="field_label user_login_field">Email Address</label><div class="user_login_field text_input_with_sprite text_input_with_sprite_16x16 mbm"><input id="login" class="text_input login_email ram field_element " name="login" type="email" title="Email Address" placeholder="Email Address" value="email#gmail.com"> <label class="icon" for="login" title="Email Address"></label></div><label for="password" class="field_label user_password_field">Password</label><div class="user_password_field text_input_with_sprite text_input_with_sprite_16x16 mbm"> <input id="password" class="text_input login_password ram field_element" name="password" title="Password" placeholder="Password" type="password" autocapitalize="off" autocomplete="off" autocorrect="off" value="passwordstring"> <label class="icon" for="password" title="Password"></label></div> </div> <div class="login_submit_div"><input class="btn btn-primary mhn login_submit fw pvm ram" title="Authorize" value="Authorize" type="submit" name="login_submit"></div> <input type="hidden" name="dologin" value="1" /> <input type="hidden" name="client_id" value="99hxwc5z7wz" /><input type="hidden" name="response_type" value="code" /><input type="hidden" name="redirect_uri" value="http://localhost:8080/" /><input type="hidden" name="scope" value="root_readwrite manage_groups manage_enterprise_properties manage_app_users manage_managed_users" /><input type="hidden" name="folder_id" value="" /><input type="hidden" name="file_id" value="" /> <input type="hidden" name="state" value="Licg8fhDiFyobsV" /> <input type="hidden" name="reg_step" value="" /><input type="hidden" name="submit1" value="1" /><input type="hidden" name="folder" value="" /><input type="hidden" name="login_or_register_mode" value="login" /><input type="hidden" name="new_login_or_register_mode" value="" /><input type="hidden" name="__login" value="1"><input type="hidden" name="redirect_url" value="/api/oauth2/authorize?response_type=code&redirect_uri=http://localhost:8080/&client_id=99hxwc5z7p9g3z&state=LichV8eTbbtXbsV"><input type="hidden" name="request_token" value="5d6b31164f15f58bebff206db0aa595eaa90f5f9b857860f8ac3e64c85a5b5f4"> <input type="hidden" id="_pw_sql" name="_pw_sql" value=""/>
</div>
<div class="sso_switch option_sso mts pvs phm hidden">
Use Single Sign On (SSO)
Use Box account credentials
</div>
</form>
and now i want to submit this form to the url specified in action parameter of form tag. Same as it will be submitted from a browser. And condition is i should not use beego webserver for this.
Thanks in advance
If I understand you correctly, you have to work with an HTML form as opposed to just the input values, and you want to send the input contained in that form to some other server for processing, and you also want to do this programmatically with Go as opposed to clicking on a button inside a browser.
If I got that right, what you have to do is first get the input values, action url, and method from the form. You can do that by using golang.org/x/net/html for example.
After you have all the necessary values you'll have to encode the input values into a valid application/x-www-form-urlencoded string which you can do using the net/url package.
Then all you have to do is to create an http request with http.NewRequest using the form method and action url as it's first two arguments and the urlencoded string as it's last body argument. (You can use strings.NewReader to turn a string into an io.Reader.)
Finally call http.Client.Do on the http.DefaultClient with the newly created request as it's argument.
It's possible that there are some 3rd party packages that do most of this work for you, so if you want to avoid doing this yourself try searching through github.

In Paypal, how to set up shipping in one lump sum? Shipping field isn't processing correctly

I am setting up an online store. I would like to itemize products and charge shipping separately in one lump sum. I have created hidden input fields with names as follows:
<input type="hidden" name="item_name_1" value="My Product 1" />
<input type="hidden" name="amount_1" value="80.00" />
<input type="hidden" name="quantity_1" value="2" />
<input type="hidden" name="item_name_2" value="My Product 2" />
<input type="hidden" name="amount_2" value="20.00" />
<input type="hidden" name="quantity_2" value="3" />
etc
I am creating a hidden input field for the shipping cost as follows:
<input type="hidden" name="shipping" value="20" />
and a hidden input field for the tax amount:
<input type="hidden" name="tax_cart" value="22" />
When the data is posted to the PayPal site, the items appear and the tax appears but the shipping cost is omitted. The field name "shipping" seems to be consistent with what is stated in the Paypal developers' guide.