I have a form which gets user's telephone and stores it in an database. Then I am fetching data from the database and place it on placeholder like this.
Telephone<input name="telephone" type="text" size="25" placeholder="<?php echo $user_data_profile['telephone']; ?>"/>
everything is fine. I want to make the placeholder's data to appear as an editable text, so that the user will have the option to change his telephone number easy. Any suggestions?
I would suggest:
Telephone
<input name="telephone" type="text" size="25"
placeholder="xxx-xxx-xxxx" value="<?=$user_data_profile['telephone']?>"/>
Using whatever phone number format that is relative to your area.
Related
I have a a page where users create and account and edit password if the account already exists. I'm using php - codeigniter
When users update passwords, the input field currently allows them to change their username as well as their password. I'm trying to make it so that users can only update passwords and not usernames but I have had trouble doing so.
This is my code
<input required type="text"
placeholder="page name"
value="<?= $form_value['name'] ?>" name="name" id="name">
I am trying to make it so that the username is printed but it is not updated.
The only thing I can think of is making the input type hidden (as shown in the below code), but then users can minipulate it and change it in the inspect element option of the browser and update their users.
<input required type="hidden" placeholder="page name" value="<?= $form_value['name'] ?>" name="name" id="name">
I am not sure what to do,
Thanks in advance
use should echo your php variable to get its value inside your html input element
<input required type="text" placeholder="page name" value="<?= echo $form_value['name']; ?>" name="name" id="name">
in the above syntax you are using php shorthand syntax, so you should enable it first. you can use like this also without short tags
<input required type="text" placeholder="page name" value="<?php echo $form_value['name']; ?>" name="name" id="name">
I assume you're using a database to store this information. If that is the case - just don't update the username field when you are updating the password. There are many cases where the user could go into inspect element and change things, but all that matters is what you're doing on the back-end.
Just echo the plain username without input field (if user is logged in) & empty input field (for new user registration), while update take the user_id from session & update the respective password of the logged in user.
Basic HTML PHP CSS. I have an edit box with a placeholder. In the case that I have edited the fields once before (like username and password), and the browser has cached them, and I return to the form again (e.g., the login page), both the placeholder text and the auto filled values are appearing over top of each other. This is using the osclass code, if that matters. Clicking in the edit box removes the placeholder text, and the auto-filled value remains.
Thanks for the help!
Here's the site -
letmeborrowthat
You should turn the autocomplete off in your code
i.e.,
<input id="email" type="text" name="email" value="" class="input-text" autocomplete="off">
<input id="password" type="password" name="password" value="" class="input-text" autocomplete="off">
You can read it from the mdn here
I've got a question and I hope someone of you have a solution for this.
Well I have this code:
<input type="text" id="username" placeholder="Email/Username"
class="Username placeholder NoPlaceholder text"
title="Email/Username" name="usern" value=""
required="required" tabindex="1" maxlength="30"/>
I would like to limit this input field to only allow a full email address.
So to disallow other symbols like: !#$%^&*()_+{}|:">?<
Input pattern won't work as someone can just delete that by inspecting element.
If someone has a tip or idea comment below!
just use HTML5 field validator:
<form>
<input type="email" name="email" autocomplete="off">
<input type="submit" value="Submit">
</form>
This will force the user to enter a text string, which makes sense for an email address..
Success!
Don't use a text type, use HTML5's email type:
<input type="email" name="email">
Assuming a situation like this, a page with simple form input phone number and it allow multi user - access:
<form>
Name: * <input type="text" name="name" /><br />
Phone: (if any) <input type="text" name="phone" /><br />
</form>
The phone field in database is pre-defined as allow-null.
The problem is when user A inputting the form , user B modify the database and set phone field as not-null . When user A submit , the phone will be a null value and post to the mysql database.
What i want to achieve is , if that field is modifyied to non-null, it should refresh before submit, retrieve the database structure before submit. Once there is difference, it return to the form and display like the following
<form>
Name: * <input type="text" name="name" /><br />
Phone: * <input type="text" name="phone" /> Sorry. You have to enter phone number<br />
</form>
How can it implement base on php(if possible)/ ajax? Thanks for the help.
Its quite weird to implement any refresh before submit and make decisions on browser side.
Such a situation should be checked on PHP side (after submit), which should return an error result-code meaning "The field is not null any more, please provide a value"
We have a very large form and we are posting the data to mysql using $_POST, but we have 2 complex sections in the form where we need your help.
HTML markup of form
<label>Customer Name</label>
<input type="text" size="50" name="name" />
<label>Education</label>
<input type="text" size="50" name="class" />
<input type="text" size="50" name="board" />
<input type="text" size="50" name="subjects" />
<input type="text" size="50" name="aggregate" />
<label>Payment Plan</label>
<ul id="fields"></ul>
We are appending following to #fields using jquery
<li><input type="text" size="30" name="date" /> <input type="text" size="30" name="amount" /> </li>
Now we would like your help with the following problems...
How to post education details to mysql table? - using php serialise?
how to post appended input boxes to mysql's tbl.paymentplan?
If you've populated the fields using jquery (date & amount) and it's on the form, a simple "Submit" button which posts to a PHP page that handles the insert into the database should work fine.
Nothing complex about it. I use jquery to pre-load form data all the time like that.
If you want to avoid doing a postback entirely, and want to do that through jquery as well, you can. Once the data is loaded into the DOM and the form displays it you can do with it what you want.
Algorithm
use mysql_fetch_field to know all attributes name from your table
if attribute does not exist in current table then update table via php like below
mysql_query("ALTER TABLE paymentplan
ADD date CHAR(30) AFTER subject,
Add payment CHAR(30) AFTER date");
and then insert the data the way u want.
Reference
mysql fetch field