Login | Register | FAQ
Anonymous

adding phone number to a form and echo it out

+ Post a reply

Page 1 of 1


adding phone number to a form and echo it out

by roadrunner2414 » Thu Aug 08, 2013 9:29 am

Hi Guys not sure if I have written this correctly.

I am trying to add the phone number to a settings form that can update a customers data

here is the code, can someone with there expertise help me please.

I really would appreciate your help

thank you

roadrunner2414


include 'core/init. ';
protect_page();
include 'includes/overall/header. ';
echo "<p>Current date and time: " . date("r") . "</p>";
if (empty($_POST) === false) {
$required_fields = array('first_name', 'email');
foreach($_POST as $key=>$value) {
if (empty($value) && in_array($key, $required_fields) === true) {
$errors[] = 'Fields marked with an asterisk are required';
break 1;
}
}

if (empty($errors) === true) {
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'A valid email address is required';
} else if (email_exists($_POST['email']) === true && $user_data['email'] !== $_POST['email']) {
$errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already in use';
}
}
}


<h1>Settings</h1>


if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
echo 'Your details have been updated!';
} else {
if (empty($_POST) === false && empty($errors) === true) {

$update_data = array(
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
'email' => $_POST['email'],
'cellphone' => $_POST['cellphone'],
'phone' => $_POST['phone'],
'allow_email' => ($_POST['allow_email'] == 'on') ? 1 : 0
);

update_user($session_user_id, $update_data);
header('Location: settings.php?success');
exit();

} else if (empty($errors) === false) {
echo output_errors($errors);
}


<form action="" method="post">
<ul>
<li>
First name*:<br>
<input type="text" name="first_name" value="<?php echo $user_data['first_name']; ?>">
</li>
<li>
Last name:<br>
<input type="text" name="last_name" value="<?php echo $user_data['last_name']; ?>">
</li>
<li>
Email*:<br>
<input type="text" name="email" value="<?php echo $user_data['email']; ?>">
</li>
<li>
Home or Work Phone:<br>
<input type="text" name="phone" value="<?php echo $user_data['phone']; ?>">
</li>
<li>
<input type="checkbox" name="allow_email" <?php if ($user_data['allow_email'] == 1) { echo 'checked="checked"'; } ?>> Would you like to receive email from us?
</li>
<li>
<input type="submit" value="Update">
</li>
</ul>
</form>


}
include 'includes/overall/footer.php';
User avatar

roadrunner2414

  • Posts: 3
  • Joined: Thu Aug 08, 2013 9:00 am

Re: adding phone number to a form and echo it out

by XainPro » Wed Aug 14, 2013 9:47 pm

its check it it's working or not then ask for help
i think you have added it here

Home or Work Phone:<br>
<input type="text" name="phone" value="<?php echo $user_data['phone']; ?>">
User avatar

XainPro

  • Posts: 2401
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: adding phone number to a form and echo it out

by roadrunner2414 » Fri Aug 16, 2013 7:06 am

Hi thank you so much for your reply,

yes you are right i have added it sadly it wont work when i dislay it on the form on the web site it is black and will not update ?

Any ideas

roadrunner2414
steve jones


XainPro wrote:its check it it's working or not then ask for help
i think you have added it here

Home or Work Phone:<br>
<input type="text" name="phone" value="<?php echo $user_data['phone']; ?>">
User avatar

roadrunner2414

  • Posts: 3
  • Joined: Thu Aug 08, 2013 9:00 am

Re: adding phone number to a form and echo it out

by roadrunner2414 » Tue Aug 20, 2013 11:15 am

Hi all,
In particular to xaim

I have solved the problem thanks after ;looking at all my code, I had forgotten to put the field phone in my users function. It all nw works

thanks again

roadrunner
User avatar

roadrunner2414

  • Posts: 3
  • Joined: Thu Aug 08, 2013 9:00 am


+ Post a reply

Page 1 of 1