简体   繁体   中英

codeigniter edit details page

I have a page where user can go to edit the information he entered about himself. This is the code:

<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

</head>
<body dir="rtl">



<?php echo form_open('profile/edit'); ?>

<h5>الاسم الكامل</h5>
<input type="text" name="fullname" value="<?php echo $fullname; ?>" />

<h5>الايميل</h5>
<input type="text" name="email" value="<?php echo $email; ?>"  />


<h5>الجوال</h5>
<input type="text" name="mobile" value="<?php echo $mobile; ?>"  />

<h5>هاتف</h5>
<input type="text" name="telephone" value="<?php echo $telephone; ?>" />

<h5>العنوان</h5>
<input type="text" name="address" value="<?php echo $address; ?>"  />

<h5>نبذة عني</h5>
<textarea rows="4" cols="50" name="about" value="<?php echo $about; ?>"> </textarea>
<br><br>

<div><input type="submit" value="Submit" /></div>

</form>

</body>
</html>

Now when I submit, it shows me these errors:

在此处输入图片说明

I don't know what is happening. This only happens when I submit the form with edited data. Otherwise, it is loading correct details inside the fields in the first place.

Your help greatly appreciated: :)

Try it .

<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

</head>
<body dir="rtl">



<?php echo form_open('profile/edit'); ?>

<h5>الاسم الكامل</h5>
<input type="text" name="fullname" value="<?php echo (!empty($fullname)?$fullname:""); ?>" />

<h5>الايميل</h5>
<input type="text" name="email" value="<?php echo (!empty($email)?$email:""); ?>"  />


<h5>الجوال</h5>
<input type="text" name="mobile" value="<?php echo(!empty($mobile)?$mobile:""); ?>"  />

<h5>هاتف</h5>
<input type="text" name="telephone" value="<?php echo (!empty($telephone)?$telephone:""); ?>" />

<h5>العنوان</h5>
<input type="text" name="address" value="<?php echo (!empty($address)?$address:""); ?>"  />

<h5>نبذة عني</h5>
<textarea rows="4" cols="50" name="about" value="<?php echo (!empty($about)?$about:""); ?>"> </textarea>
<br><br>

<div><input type="submit" value="Submit" /></div>

</form>

</body>
</html>

Is there any reason why you're not using the form helper class to generate the fields? Be sure the class is loaded via $this->load->helper('form'); first and foremost. You can use form input helper via echo form_input('username', 'johndoe'); . Also, your issue lies in your value fields. $fullname doesn't have a value so you'll need to compensate by doing something like:

// using HTML
<input type="text" name="fullname" value="<?php echo isset($fullname) ? $fullname : ''; ?>" />

// using form_input()
$data = array(
    'type' => 'text',
    'name' => 'fullname',
    'value' => isset($fullname) ? $fullname : ''
);
echo form_input($data);

Hopefully this helps you!

are you sure of setting the value to the view that have all the user info like email etc. Better you check you repopulating info before rending to view with user info.

and in the view you have check the variable alreedy set or not by (!empty($fullname)? echo $fullname: '');

hope this will help !!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM