I don’t know why, but everything works fine on my local environment, but when i upload to D.O, my forms don’t seem to send data to my database. my connection is correct . is it because i tend to use action="<?php echo $_SERVER['PHP_SELF']?>" ? is there any alternative? i’m freaking out because i used throughout my whole project…
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Can you share the rest of your script? The first step in debugging this type of issue would be to look for anything recorded in your error log /var/log/apache2/error.log
Using this environment variable to set the form target shouldn’t be a problem as long as php is functioning properly.
<form class="form awesome-form" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<section class="form-group col-md-12">
<input type="text" class="form-control" name="hostel-name" id="hostel-name" autocomplete="off" required>
<label> Name</label>
</section>
<section class="form-group col-md-12">
<input type="email" class="form-control" name="email" id="email" autocomplete="off" required>
<label>Email</label>
</section>
<section class="form-group col-md-12">
<input type="email" class="form-control" name="conf-email" id="conf-email" autocomplete="off" required>
<label>Confirm Email</label>
</section>
<section class="form-group col-md-12">
<input type="password" class="form-control" name="password" id="password" autocomplete="off" required>
<label>Password</label>
</section>
<section class="form-group col-md-12">
<button class="form-control " name="register" id="register-btn" type="submit" ><span class="fa fa-paper-plane"> Sign Up</span></button>
</section>
<section class="form-group">
<ul class="list-inline" style="display: block;">
<li class="pull-left"> Have an Account?</li>
<li class="pull-right"><a href="login.php">Log in!</a></li>
</ul>
</section>
</section>
</form>
for the insert script
<?php
include 'database/connection.php';
$hostel_name=$_POST['hostel-name'];
$email=filter_var($_POST['email'],FILTER_VALIDATE_EMAIL);
$password=hash('sha256',$_POST["password"]);
$confemail=filter_var($_POST['conf_email'],FILTER_VALIDATE_EMAIL);
$confirm_code=md5(uniqid(rand()));
$user_id=md5(rand(0,10000));
//new block added
if($name="" or $email=="" || $password=="" || $confemail=="" ){echo '<p class="alert alert-danger text-center">Please Make Sure All Fields Are Filled <span class="close pull-right"><span class="close pull-right"> <a href="#" >×</a></span></p>';}
elseif($email==$confemail){
$query=$dbc->query("select email from users where email='$email'");
if($result=$query->fetch(PDO::FETCH_NUM)!=0){ echo '
<p class="alert alert-danger text-center">We already have someone with that email <span class="close pull-right"><span class="close pull-right"> <a href="#" >×</a></span></p>'; }elseif($result=$query->fetch(PDO::FETCH_NUM)==0){
$data_result=$dbc->query("insert into users(hostel_name,email,password,confirm_code,user_id) values('$hostel_name','$email','$password','$confirm_code','$user_id')");
if($data_result){
echo '<p class="alert alert-success text-center error-message"> You\'re almost there! Check your inbox to activate your account.</p>';
}
}
}else{
echo '<p class="alert alert-danger text-center error-message">Something is not right <span class="pull-right close"> <a href="#" >×</a></span></p>';}
$dbc=null;
?>
i know am exposed to sql injection but i just want to see the data inserted first
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.