Magento Telphone filed in Customer_Account_Edit page - php

I want to do the same as this guy do
Magento: How to display customer's phone number on customer information field
but I don't want only to display the customer phone number, I want to give ability to change the telephone number on this page.
If I follow the guy's above solution I only get the Telephone display in a field but when I submit the form everything else is being saved except this telephone field. What could be the code solution to save the new information after FormSubmission?
Thanks in advance
UPDATE #1
I update /app/design/frontend/base/default/template/customer/form/edit.phtml with this code
<input type="text" placeholder="<?php echo $this->__('Telephone') ?>" name="telephone" value="<?php echo $this->getCustomer()->getPrimaryBillingAddress()->getTelephone() ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="telephone" />
but it doesn't save (form omit changes) if I change the input value and submit the form.
I wonder why..

Related

How to echo and auto increment receipt number in php?

I have a database, and table fees. In which I have to generate a receipt of each payment. But I want that receipt number field must first echo receipt number which is one increment (+1) of last receipt number. For example, last receipt is 1 than new receipt should be 2 and non editable.
I am bit confused in that.
My field code is:
<label class="field-title">Reciept Number <span class="form-req">*</span></label>
<input type="text" name="reciept_number" class="span4" value="<?php
$data = max(mysqli_fetch_array(mysqli_query($conn,"SELECT reciept_number FROM fees"))); echo $data; ?>" readonly>
Dont understand your question exactly but maybe you want something like this:
<label class="field-title">Reciept Number <span class="form-req">*</span></label>
<input type="text" name="reciept_number" class="span4" value="
<?php
$data = mysqli_fetch_row(mysqli_query($conn,"SELECT max(reciept_number)+1 FROM fees"));
echo $data[0];
?>" readonly>

Overwrite input value in form field

I have an "Update Profile" script that retrieves the details of the logged in user in a form input, so they can see what the current values are. Like this:
<input type="text" name="first_name" id="first_name" value='<?= $row->f_name; ?>' title="enter your first name.">
This works. When users navigate to the page they see their first name appear in that input box. When they go to change their name and enter in a new value the form submits but keeps the original value and not the updated one. I assume that is because I am hard-coding a value to it with the value attribute.
How can I show the user the value in the input so that if they choose to not edit it, it does submit with the original value and not a blank, but if they do choose to add text to the input box the new string is submitted?
If I understand you correctly:
value="<?=set_value('first_name', $first_name)?>"
The first parameter is the posted value, the second parameter is the default overridden value.
You may want to use placeholder attributes.
<input type="text" name="first_name" placeholder="<?= $row->f_name; ?>">
`if($_GET['first_name']==''){
$first_name= $row->f_name;
}else{
$first_name= $_GET['first_name'];
}`
SQL Query :
"UPDATEyour_table_nameSETfirst_name= '$first_name' WHEREblablabla= '$blablalba';"
&ltinput type="text" name="first_name" id="first_name" value='f_name; ?>' title="enter your first name.">

How to Set fields as Readonly

I have added two fields [ Start_date and End_Date] in Project , can able to update and save values in the fields.
I want to allow fields editable when EDIT button clicked otherwise it should be readonly.
Code changes but doesn't works
<label for="txtstartdate"><?php echo __("Start Date")?> <span class="required">*</span></label>
<input id="txtstartdate" name="txtstartdate" type="text" class="formInputText" disabled="disabled" value="<?php echo $project->getstartDate()?>" disabled />
<br class="clear"/>
function disableWidgets(){
$('#addProject_start_date').attr('disabled','disabled');
$('#addProject_end_date').attr('disabled','disabled');
}
function enableWidgets(){
$('#addProject_start_date').removeAttr('disabled');
$('#addProject_end_date').removeAttr('disabled');
}
In which file i have to change . Any one could help me to achieve this?

Sending PHP variables back and forth between pages

I've created a registration form that successfully passes its variables from the registration page (go-gold.php) to a summary/verfication page (go-gold-summary.php). The data appears correctly on the second page.
However, I want to able to use an image button to return back to the registration page, in case the user made an entry error. Going back, the original form should now be populated with the data that was first entered.
The problem is that I cannot re-send/return the data from the second page, back to the first. My text fields appear blank. I do NOT want to use Session variables.
The code is truncated from the entire page.
Registration Page (go-gold.php):
<?php
$customer_name = $_POST['customer_name'];
?>
<form action="go-gold-summary.php" method="post">
Name: <input type="text" name="customer_name" id="customer_name" value= "<?php echo $customer_name ?>" />
<input name="<?php echo $customer_name ?>" type="hidden" id="<?php echo $customer_name ?>">
</form>
Summary Page (go-gold-summary.php)
<?php
$customer_name = $_POST['customer_name'];
?>
<form action="go-gold.php" method="post">
Name: <?php echo $customer_name ?> <input type="hidden" id="<?php echo $customer_name ?>" name="<?php echo $customer_name ?>">
<INPUT TYPE="image" src="images/arrow_back.png" id="arrow" alt="Back to Registration"> (Button to go back to Registration Page)
</form>
Thanks!
go-gold-summary.php should be changed like this.
<?php
$customer_name = $_POST['customer_name'];
?>
<form action="go-gold.php" method="post">
Name: <?php echo $customer_name ?> <input type="hidden" value="<?php echo $customer_name ?>" name="customer_name">
<INPUT TYPE="submit" src="images/arrow_back.png" id="arrow" alt="Back to Registration"> (Button to go back to Registration Page)
</form>
notice how I've changed this line
<input type="hidden" id="<?php echo $customer_name ?>" name="<?php echo $customer_name ?>">
into this
<input type="hidden" value="<?php echo $customer_name ?>" name="customer_name">
$_POST is an associative array and as you submit the form it will be populated like this:
$_POST["index"] = value;
where "index" is the text field "name" and value is the text field value.
You've missed that one in your code. Just update it with my code and it will work
Why you would not want to use the php session? Please give any reason for not to use it. I am asking this way since my reputation does not allow me to comment questions or answers any other than my own. Plese do not -1 for this.
Another way could be using cookies to store the data temporarily, but that and posting the data back and forth in the post request is really insecure compared to session.
there are very few ways to maintain variables across pages. The alternative is to have separate form on the second page with hidden text fields containing the $_POST data, and the submit button calls the previous page. No way of getting around the "back button" on a browser though unfortunately.
I missed the bold text about the session variables - disregard if this does not apply:
one way to maintain variables across pages on the server side is to use $_SESSION
first include the following at the top of your PHP pages to keep a session active:
session_start();
once you submit the for and move to page 2, add the following:
$_SESSION['customer_name'] = $_POST['customer_name'];
As well, on the first page, you could change the form element as such:
<input type="text" name="customer_name" value="<?PHP if isset($_SESSION['customer_name'] || !empty($_SESSION['customer_name'])) { echo $_SESSION['customer_name']; } ?>">
this will keep the filled in data and display it when the user returns tot he page, and if they put in something different it will be updated when they hit page 2 again.

Please Help Me With A PHP Form From A Theme - I need to change fields to spanish

I hope you can help me out, I am using a Wordpress Theme. It comes with a page template of a form. You can see the form functioning at my url:
http://getpaidtotryitfree.com/contactenos/
This is a URL for a different project. I took it down so I could put my client´s website up. I cannot figure out how to change the fields to show up in spanish. Here is the code:
http://getpaidtotryitfree.com/wp-content/themes/13Floor/contact.txt
<input type="text" name="et_contact_name" value="<?php if ( isset($_POST['et_contact_name']) ) echo esc_attr($_POST['et_contact_name']); else esc_attr_e('Name','13floor'); ?>" id="et_contact_name" class="input" />
So I went through all the "values" and chanded the part in parenthesis to ('Nombre','13floor') and so on for all other values.
When I did that the field wouldn´t dissapear on click, like it does right now, so I thought "thats alright" i´ll just highlight it and fill it in but once I did that it activated the error "Please Fill In All Fields" so it didnt accept that. Ok...So then I did:
Press Control + F, to find all the places with "et_contact_name" and changed it to "et_contact_nombre", I started with:
<input type="text" name="et_contact_**nombre**" value="<?php if ( isset($_POST['et_contact_**nombre**']) ) echo esc_attr($_POST['et_contact_**nombre**']); else esc_attr_e('Nombre','13floor'); ?>" id="et_contact_**nombre**" class="input" />
Then with the Control + F command I found all others like:
$et_site_name = is_multisite() ? $current_site->site_name : get_bloginfo('name');
wp_mail($et_email_to, sprintf( '[%s] ' . esc_html($_POST['et_contact_subject']), $et_site_name ), esc_html($_POST['et_contact_message']),'From: "'. esc_html($_POST['et_contact_**nombre**']) .'" <' . esc_html($_POST['et_contact_email']) . '>');
And did the same process with email,subject,message,etc. No luck though, the form didnt work then, it did change the fields, but it was not functional. (The highlighting deal I told you earlier)
I was able to change:
<input class="et_contact_submit" type="submit" value="<?php esc_attr_e('**Enviar**','13floor'); ?>" id="et_contact_submit" />
Which was "submit" this changed the text in the button, and left the form functional, I wish all other fields were as simple lol.
Ok and aside from this, there is no place in the .php where I can see how to change the error activations like:
Fill Name field
Fill Email Address field
Invalid email
Fill Subject field
Fill Captcha field
Fill Message field
I only see this piece of code:
$et_contact_error = true;
} else if ( empty($_POST['et_contact_name']) || empty($_POST['et_contact_email']) || empty($_POST['et_contact_subject']) || empty($_POST['et_contact_message']) ){
$et_error_message .= '<p>' . esc_html__('**Make sure you fill all fields**. ','13floor') . '</p>';
$et_contact_error = true;
But "Make sure you fill all fields" never even comes up when using the actual form, so as you can see I am completely lost I hope you can help me out, I would greatly appreciate it.
Thanks for contacting us
The default values for the fields are stored in
http://getpaidtotryitfree.com/wp-content/themes/13Floor/epanel/page_templates/js/et-ptemplates-frontend.js?ver=1.1
lines 67-70.
UPDATE
Yes, you should also translate the values in the form, you can find them at
... else esc_attr_e('XXXXX','13floor'); ...
and at
... esc_textarea('Mensaje','13floor'); ...
Example:
...
<input type="text" name="et_contact_name" value="<?php if ( isset($_POST['et_contact_name']) ) echo esc_attr($_POST['et_contact_name']); else esc_attr_e('Nombre','13floor'); ?>" id="et_contact_name" class="input" />
...
<input type="text" name="et_contact_email" value="<?php if ( isset($_POST['et_contact_email']) ) echo esc_attr($_POST['et_contact_email']); else esc_attr_e('Email','13floor'); ?>" id="et_contact_email" class="input" />
...
<input type="text" name="et_contact_subject" value="<?php if ( isset($_POST['et_contact_subject']) ) echo esc_attr($_POST['et_contact_subject']); else esc_attr_e('Sujetos','13floor'); ?>" id="et_contact_subject" class="input" />
...
<textarea class="input" id="et_contact_message" name="et_contact_message"><?php if ( isset($_POST['et_contact_message']) ) echo esc_textarea($_POST['et_contact_message']); else echo esc_textarea('Mensaje','13floor'); ?></textarea>

Categories