I am trying to create a login and signup feature on my website but for some reason, I can't create a user. and it's not showing any error.
I have done these before in another code but I don't know why it is not working in this one.
And also when I refresh the website, it asks if it should resubmit the form.
These are the codes below
index.html
<div class="main-register">
<div class="close-reg"><i class="fal fa-times"></i></div>
<ul class="tabs-menu fl-wrap no-list-style">
<li class="current"><i class="fal fa-sign-in-alt"></i> Login</li>
<li><i class="fal fa-user-plus"></i> Register</li>
</ul>
<!--tabs -->
<div class="tabs-container">
<div class="tab">
<!--tab -->
<div id="tab-1" class="tab-content first-tab">
<div class="custom-form">
<form method="post" action="" name="registerform">
{% csrf_token %}
{% for message in messages %}
<h4 style="color: red;">{{message}}</h4>
{% endfor %}
<label>Email Address * <span class="dec-icon"><i class="fal fa-user"></i></span></label>
<input name="email" type="email" placeholder="Your Mail" onClick="this.select()" value="">
<div class="pass-input-wrap fl-wrap">
<label >Password * <span class="dec-icon"><i class="fal fa-key"></i></span></label>
<input name="password" placeholder="Your Password" type="password" autocomplete="off" onClick="this.select()" value="" >
<span class="eye"><i class="fal fa-eye"></i> </span>
</div>
<div class="lost_password">
Lost Your Password?
</div>
<div class="filter-tags">
<input id="check-a3" type="checkbox" name="check">
<label for="check-a3">Remember me</label>
</div>
<div class="clearfix"></div>
<button type="submit" class="log_btn color-bg"> LogIn </button>
</form>
</div>
</div>
<!--tab end -->
<!--tab -->
<div class="tab">
<div id="tab-2" class="tab-content">
<div class="custom-form">
<form method="POST" id="registerform" class="main-register-form" name="registerform">
{% csrf_token %}
{% for message in messages %}
<h4 style="color: red;">{{message}}</h4>
{% endfor %}
<label >Full Name * <span class="dec-icon"><i class="fal fa-user"></i></span></label>
<input name="full_name" type="text" placeholder="Your Name" onClick="this.select()" value="">
<label>Email Address * <span class="dec-icon"><i class="fal fa-envelope"></i></span></label>
<input name="email" type="text" placeholder="Your Mail" onClick="this.select()" value="">
<div class="pass-input-wrap fl-wrap">
<label >Password * <span class="dec-icon"><i class="fal fa-key"></i></span></label>
<input name="password" type="password" placeholder="Your Password" autocomplete="off" onClick="this.select()" value="" >
<span class="eye"><i class="fal fa-eye"></i> </span>
</div>
<div class="filter-tags ft-list">
<input id="check-a2" type="checkbox" name="check">
<label for="check-a2">I agree to the Privacy Policy and Terms and Conditions</label>
</div>
<div class="clearfix"></div>
<button type="submit" class="log_btn color-bg"> Register </button>
</form>
</div>
</div>
</div>
<!--tab end -->
</div>
views.py
def index(request):
return render(request, 'index.html')
def signup(request):
if request.method == 'POST':
full_name = request.POST['full_name']
email = request.POST['email']
password = request.POST['password']
if User.objects.filter(email=email).exists():
messages.info(request, 'Email is taken')
return redirect('index.html')
else:
user = User.objects.create_user(full_name=full_name, email=email, password=password)
user.save()
user_model = User.objects.get(full_name=full_name)
new_profile = user_profile.objects.create(user=user_model, id_user=user_model.id)
new_profile.save()
return redirect('index.html')
else:
return render(request, 'index.html')
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
models.py
from django.db import models
from django.contrib.auth import get_user_model
User =get_user_model()
# Create your models here.
class user_profile(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
id_user = models.IntegerField()
location = models.CharField(max_length=120, blank=True)
def __str__(self):
return self.user.full_name
Related
I wanna create a appointment system but its not working now. I'dont have a error actually i just have a error and it's coming from views.py (messages.warning(request,"ERROR!")). When i opened the page its coming anyway i just wanna send my informations.
models.py: I created models but im not sure for policlinic and doctor because it doesn't seems like charfield text. It's a option field in HTML.
class Randevu(models.Model):
STATUS = (
('New', 'Yeni'),
('True', 'Evet'),
('False', 'Hayır'),
)
policlinic=models.ForeignKey(Policlinic,on_delete=models.CASCADE)
user=models.ForeignKey(User,on_delete=models.CASCADE)
doctor=models.ForeignKey(Doctors,on_delete=models.CASCADE)
phone = models.CharField(max_length=15)
email = models.CharField(max_length=50)
date=models.DateField(null=True)
time=models.TimeField(null=True)
payment= models.CharField(max_length=50)
insurance= models.CharField(max_length=50)
note=models.TextField(max_length=200)
status = models.CharField(max_length=10, choices=STATUS,default='New')
ip=models.CharField(max_length=20,blank=True)
create_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
def str(self):
return self.user.username
class AppointmentForm(ModelForm):
class Meta:
model=Randevu
fields=['phone','email','date','time','payment','insurance','note']
views.py:
def randevu(request):
setting=Setting.objects.get(pk=1)
policlinic=Policlinic.objects.all()
doctor=Doctors.objects.all()
context={'setting':setting ,'doctor':doctor,'policlinic':policlinic}
if request.method=='POST':
form=AppointmentForm(request.POST)
if form.is_valid():
current_user=request.user
data=Randevu()
data.user_id=current_user.id
data.phone=form.cleaned_data['phone']
data.email=form.cleaned_data['email']
data.date=form.cleaned_data['date']
data.time=form.cleaned_data['time']
data.payment=form.cleaned_data['payment']
data.insurance=form.cleaned_data['insurance']
data.note=form.cleaned_data['note']
data.ip=request.META.get('REMOTE_ADDR')
data.save()
messages.success(request,"DONE! :)")
return render(request,'randevu.html',context)
messages.warning(request,"ERROR!")
return render(request,'randevu.html',context)
urls.py
urlpatterns = [
path('randevu',views.randevu,name='randevu') ]
randevu.html
<!-- MAKE AN APPOINTMENT -->
<section id="appointment" data-stellar-background-ratio="3">
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-6">
<img src="{% static 'images/appointment-image.jpg' %}" class="img-responsive" alt="">
</div>
<div class="col-md-6 col-sm-6">
<!-- CONTACT FORM HERE -->
<form id="appointment-form" role="form" action="{% url 'randevu' %}" method="post">
<!-- SECTION TITLE -->
<div class="section-title wow fadeInUp" data-wow-delay="0.4s">
<h2>Randevu Alın</h2>
{%if messages%}
{%for message in messages%}
<div class="alert alert-{{message.tags}}"role="alert">
{{message}}
</div>
{%endfor%}
{%endif%}
</div>
{% csrf_token %}
<div class="wow fadeInUp" data-wow-delay="0.8s">
<div class="col-md-6 col-sm-6">
<label for="email">E-mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Your Email">
</div>
<div class="col-md-6 col-sm-6">
<label for="telephone">Telefon Numaranız</label>
<input type="tel" class="form-control" id="phone" name="phone" placeholder="Phone">
</div>
<div class="col-md-6 col-sm-6">
<label for="date">Tarih</label>
<input type="date" name="date" id="date" value="" class="form-control">
</div>
<div class="col-md-6 col-sm-6">
<label for="time">Zaman</label>
<input type="time" name="time" id="time" value="" class="form-control">
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Poliklinik Seçiniz</label>
<select name="policlinic" class="form-control" id="policlinic">
{% for rs in policlinic %}
<option>{{rs.title}}</option>
{%endfor%}
</select>
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Doktor Seçiniz</label>
<select name="doctor" class="form-control" id="doctor">
{% for rs in doctor %}
<option>{{rs.name}}</option>
{%endfor%}
</select>
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Ödeme Yöntemi</label>
<select name="payment" class="form-control" id="payment">
<option>Nakit</option>
<option>Banka Kartı</option>
<option>Kredi Kartı</option>
<option>Diğer</option>
</select>
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Sigorta</label>
<select name="insurance" class="form-control" id="insurance">
<option>SGK</option>
<option>AXA Sağlık Sigortası</option>
<option>Anadolu Sağlık Sigortası</option>
<option>Allianz Sağlık Sigortası</option>
<option>Akbank Sağlık Sigortası</option>
<option>Tamamlayıcı Türkiye Sağlık Sigortası</option>
<option>Diğer (Belirtiniz)</option>
</select>
</div>
<div class="col-md-12 col-sm-12">
<label for="Message">Belirtmek istediğiniz herhangi bir durum</label>
<textarea class="form-control" rows="5" id="note" name="note" placeholder="Notunuz"></textarea>
{%if user.id is not None%}
<button type="submit" class="form-control" id="cf-submit" name="submit">Submit Button</button>
{%else%}
Randevu oluşturmak için login olunuz!
{% endif %}
</div>
</div>
</form>
</div>
</div>
</div>
</section>
It's my appointment page:
enter image description here
Because get method is used to render the page
and in views.py you dont write
if request.method=='GET':
As a result, the error message is executed while there is no error
add this :
if request.method=='GET':
Hello guys hope u doing fine, I got this project and in home page of my website i have two form
1 to login and the other to upload a file however every time i submit with any form the same function keeps getting executed please help.
this is the html code
<!--login-->
<section class="bg-dark text-light p-5 text-center">
<div class="container">
<h2>First step </h2>
<form action = "http://localhost:5000" method="post" name="login" >
<div class="col">
<div class="hide-md-lg">
<h4>Sign in to your <span class="text-warning">Linkedin account</span> </h4>
</div>
<br>
<input type="text" name="username" placeholder="Username" required>
<br><br>
<input type="password" name="password" placeholder="Password" required>
<br><br>
<input class="btn btn-primary" type="submit" value="Login">
</div>
</form>
</div>
</section>
<!--upload excel-->
<section class="bg-dark text-light p-4">
<div class="container bg-primary rounded border-0 p-5">
<div class="d-md-flex justify-content-between align-items-center">
<div class="container">
<h5 class="mt-2">Choose an excel file</h5>
<h6 class="mb-3"><span class="text-warning">NB: first 2 columns have to be: "Prénom" and "Nom"</span></h6>
</div>
<form class="input-group" action = "http://localhost:5000" method = "POST" enctype = "multipart/form-data" name="upload">
<input class="form-control size-file" type="file" name="file" id="formFile">
<input class="btn btn-dark" type = "submit" value="Start scraping" >
</form>
</div>
</div>
</section>
and this is the backend part
#app.route('/', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST' :
f = request.files['file']
f.save(secure_filename(f.filename))
df = pd.read_excel(f.filename)...............
#app.route('/', methods = ['GET', 'POST'])
def login_info():
if request.method == 'POST' and 'Sign in to your' in request.form['h4']:
user_info = request.form.get("username")
pass_info = request.form.get("password")
Although unable to try it this way, I updated your code with different action parameters.
<!--login-->
<section class="bg-dark text-light p-5 text-center">
<div class="container">
<h2>First step </h2>
<form action = "{{url_for('login_info')}}" method="post" name="login" >
<div class="col">
<div class="hide-md-lg">
<h4>Sign in to your <span class="text-warning">Linkedin account</span> </h4>
</div>
<br>
<input type="text" name="username" placeholder="Username" required>
<br><br>
<input type="password" name="password" placeholder="Password" required>
<br><br>
<input class="btn btn-primary" type="submit" value="Login">
</div>
</form>
</div>
</section>
<!--upload excel-->
<section class="bg-dark text-light p-4">
<div class="container bg-primary rounded border-0 p-5">
<div class="d-md-flex justify-content-between align-items-center">
<div class="container">
<h5 class="mt-2">Choose an excel file</h5>
<h6 class="mb-3"><span class="text-warning">NB: first 2 columns have to be: "Prénom" and "Nom"</span></h6>
</div>
<form class="input-group" action = "{{url_for('upload_file')}}" method = "POST" enctype = "multipart/form-data" name="upload">
<input class="form-control size-file" type="file" name="file" id="formFile">
<input class="btn btn-dark" type = "submit" value="Start scraping" >
</form>
</div>
</div>
</section>
And the #app.route should lead to two function :
#app.route('/upload_file', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST' :
f = request.files['file']
f.save(secure_filename(f.filename))
df = pd.read_excel(f.filename)...............
#app.route('/login_info', methods = ['GET', 'POST'])
def login_info():
if request.method == 'POST' and 'Sign in to your' in request.form['h4']:
user_info = request.form.get("username")
pass_info = request.form.get("password")
If you want both those page to return to your home screen, you just have to tell them to return to this same template with render_template() or redirect()
I'm learning django now, and i'm facing a problem, I create a form to submite data in my database, but the problem is when i click on submit button, postgres isn't receiving data, I cant understand the problem.
This is my contact form
This is my database
This is my html code
<form action="." method='post' class="p-5 bg-white">
<h2 class="h4 text-black mb-5">Contact Form</h2>
{% csrf_token %}
<div class="row form-group">
<div class="col-md-6 mb-3 mb-md-0">
<label class="text-black" for="fname">First Name</label>
<input type="text" id="fname" class="form-control rounded-0">
</div>
<div class="col-md-6">
<label class="text-black" for="lname">Last Name</label>
<input type="text" id="lname" class="form-control rounded-0">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label class="text-black" for="email">Email</label>
<input type="email" id="email" class="form-control rounded-0">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label class="text-black" for="subject">Subject</label>
<input type="subject" id="subject" class="form-control rounded-0">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label class="text-black" for="message">Message</label>
<textarea name="message" id="message" cols="30" rows="7" class="form-control rounded-0" placeholder="Leave your message here..."></textarea>
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<input type="submit" value="Send Message" class="btn btn-primary mr-2 mb-2">
</div>
</div>
</form>
This is my models.py
from django.db import models
class Form(models.Model):
fname=models.CharField(max_length=300)
lname=models.CharField(max_length=300)
email=models.EmailField()
subject=models.CharField(max_length=300)
message=models.TextField()
This is my views.py
from django.shortcuts import render
from .models import Form
def test(request):
if request.method == 'POST':
request.POST.get('fname')
request.POST.get('lname')
request.POST.get('email')
request.POST.get('subject')
request.POST.get('message')
post=Form()
post.fname= request.POST.get('fname')
post.lname= request.POST.get('lname')
post.email= request.POST.get('email')
post.subject= request.POST.get('subject')
post.message= request.POST.get('message')
post.save()
else:
return render(request,'test.html')
1st. In the form action="." is not necessary as if action is empty it will be sent to the current view itself.
2nd. I suggest using Model Forms which are a lot easier.
Let's say the model name is M1.
models.py
from django.db import models
class M1(models.Model):
fname = models.CharField(max_length=300)
lname = models.CharField(max_length=300)
email = models.EmailField()
subject = models.CharField(max_length=300)
message = models.TextField()
forms.py
from django import forms
M1Form(forms.modelForm):
class Meta:
model = M1
views.py
from django.shortcuts import render
from .models import M1
from .forms import M1Form
def test(request):
if request.method == "POST":
form = M1Form(request.POST)
if form.is_valid():
form.save()
else:
return render(request, "test.html")
else:
return render(request, "test.html")
3rd. If you look at the Templates:
<input type="email" id="email" class="form-control rounded-0">
it does not have an attribute "name" in it. If you want email in request.POST It should be written like
<input type="email" id="email" name="email" class="form-control rounded-0">
Please keep in mind that the name should be the same as the model name (Since we are not overwitting the Form).
For more Documentation:
https://docs.djangoproject.com/en/3.0/topics/forms/modelforms/
I have a problem with my application the sign up is not creating profiles on the backend.
I have tried to use the django forms but I didnt like how they render so I wanted to use custom form but once I click button submit, nothing happens and I check on backend there's no profile.
My forms.py file looks like this
from django.forms import ModelForm
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from .models import Gig
class GigForm(ModelForm):
class Meta:
model = Gig
fields = ['title','category','description', 'price', 'photo', 'status']
class SignUpForm(forms.ModelForm):
first_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
last_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password' )
Models.py File like this
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
avatar = models.CharField(max_length=500)
about = models.CharField(max_length=500)
location = models.CharField(max_length=30, blank=True)
def __str__(self):
return self.user.username
signup.html looks like this
<div class="container1">
<img src="{% static 'img/home-banner.jpg' %}" class="banner">
<form action="#" name="myForm" method="post" onsubmit="return(validate());">
{% csrf_token %}
<div class="container-fluid">
<div class="row">
<div class="well center-block">
<div class="well-header">
<h1 class="text-center "><b>Sign Up</b></h1>
</br>
<hr>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</div>
<input type="text" placeholder="First Name" class="form-control"
name="{{ form.first_name.name }}"
id="{{ form.first_name.id_for_label }}"
{% if form.name.value != None %}value="{{ form.first_name.value|stringformat:'s' }}"{% endif %}
maxlength="{{ form.first_name.field.max_length }}"
{% if form.name.field.required %}required{% endif %}>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</div>
<input type="text" placeholder="Last Name" name="txtlname" class="form-control"
name="{{ form.last_name.name }}"
id="{{ form.last_name.id_for_label }}"
{% if form.name.value != None %}value="{{ form.last_name.value|stringformat:'s' }}"{% endif %}
maxlength="{{ form.last_name.field.max_length }}"
{% if form.name.field.required %}required{% endif %}>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</div>
<input type="text" placeholder="User Name" name="txtlname" class="form-control"
name="{{ form.username.name }}"
id="{{ form.username.id_for_label }}"
{% if form.name.value != None %}value="{{ form.username.value|stringformat:'s' }}"{% endif %}
maxlength="{{ form.username.field.max_length }}"
{% if form.username.field.required %}required{% endif %}>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-lock"></i>
</div>
<input type="password" minlength="8" maxlength="20" placeholder="Password" name="txtpass" class="form-control"
name="{{ form.password.name }}"
id="{{ form.password.id_for_label }}"
{% if form.password.value != None %}value="{{ form.password.value|stringformat:'s' }}"{% endif %}
maxlength="{{ form.password.field.max_length }}"
{% if form.password.field.required %}required{% endif %}>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="glyphicon glyphicon-envelope"></i>
</div>
<input type="email" class="form-control" name="txtmail" placeholder="E-Mail"
name="{{ form.email.name }}"
id="{{ form.email.id_for_label }}"
{% if form.password.value != None %}value="{{ form.email.value|stringformat:'s' }}"{% endif %}
maxlength="{{ form.email.field.max_length }}"
{% if form.password.field.required %}required{% endif %}>
</div>
</div>
</div>
</div>
<div class="row widget">
<div class="col-md-12 col-xs-12 col-sm-12">
<button class="btn btn-warning btn-block"> Submit </button>
</div>
</div>
</div>
</div>
</div>
</form>
Views.py looks like this
def signup(request):
if request.method == 'POST':
form = SignUpForm(request.POST)
if form.is_valid():
form.save()
user.refresh_from_db()
username = form.cleaned_data.get('username')
user.save()
raw_password = form.cleaned_data.get('password1')
user = authenticate(username=user.username, password=raw_password)
login(request, user)
return redirect('home.html')
else:
form = SignUpForm()
return render(request, 'signup.html', {'form': form})
Profile model has different fields from those you are passing in the signup form
in your Profile Model
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
avatar = models.CharField(max_length=500)
about = models.CharField(max_length=500)
location = models.CharField(max_length=30, blank=True)
def __str__(self):
return self.user.username
did you forget to create these fields in your forms.py
this link will help you
I'm using the Django authentication with my login form in my template, after i pressed the login button on the form the page refreshed but doesn't log me in and doesn't show the {{context}} error in the template.
My view:
def login_view(request):
if request.method == 'POST':
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts)
else:
context = 'wrong username or password'
all_categories = Categories.objects.all()
all_websites = Website.objects.all()
all_discounts = Discount.objects.order_by('-id')
return redirect('/',categories=all_categories,websites=all_websites,discounts=all_discounts,context=context)
My form (header.html)
<div class="col-md-3 top-info-cart text-right mt-lg-4">
{% if user.is_authenticated %}
<p>Welcome, {{ user.username }}.</p>
<p>logout</p>
{% else %}
<ul class="cart-inner-info">
<li class="button-log">
<a class="btn-open" href="#">
<span class="fa fa-user" aria-hidden="true"></span>
</a>
</li>
</ul>
<p>{{context}}</p>
{% endif %}
<!---->
<div class="overlay-login text-left">
<button type="button" class="overlay-close1">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<div class="wrap">
<h5 class="text-center mb-4">Login Now</h5>
<div class="login p-5 bg-dark mx-auto mw-100">
<form action="{% url 'frontend:login' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label class="mb-2">User name</label>
<input type="text" name="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your informations with anyone else.</small>
</div>
<div class="form-group">
<label class="mb-2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"type="password">
</div>
<button type="submit" class="btn btn-primary submit mb-4" value="Login">Sign In</button>
<p>Don't have an account? SIGN UP </p>
</form>
</div>
<!---->
</div>
</div>
And my urls.py:
from django.urls import path
from .import views
app_name = 'frontend'
urlpatterns = [
#index
path('',views.index, name='index'),
#/discount/id
path('<id>/',views.single,name='single'),
#/category/category_name
path('category/<name>',views.category,name='category'),
#/signup
path('signup',views.signup,name='signup'),
#/logout
path('logout',views.logout,name='logout'),
#/login
path('login',views.login_view,name='login')
]
It's because of my authentication is wrong or my view function ? i been trying to fix this but still haven't figure it out. Hope someone can help me :)