Jump to content
php.lv forumi
Treaktors

Datubāzē rādās savādāk

Recommended Posts

Sveiki! Uztaisīju uz ātro reģistrācijas formu tikai e-pastam, no sākuma gāja bet tad kaut kas nobeidzas un datubāzē e-pasta vietā rādās cipars 1 vai vispār neaizsūtās, ir kāds variants kas varētu būt pa kļūdu?

kods:

<?php
    require('connect.php');
    // If the value are posted, insert them into the database.
    $email = isset($_POST['email']);
        $query = "INSERT INTO `user` (email) VALUES ('$email')";
        $result = mysqli_query($connection, $query);
        if($result){
            $smsg = "Veiksmīgi reģistēts";
        }else{
            $fmsg ="Reģistācijas kļūda";
        }
    ?>
<html>
<head>
    <title>User Registeration Using PHP & MySQL</title>
    
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >

<link rel="stylesheet" href="styles.css" >

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
      <form class="form-signin" method="POST">
      
      <?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
      <?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>
        <h2 class="form-signin-heading">Please Register</h2>
        <div class="input-group">
      <input type="text" name='email' class="form-control" placeholder="E-Pasts" required>
    </div>
        <div class="checkbox"><input  type="checkbox" required name="checkbox" value="check" id="agree" /><a href="policy.php">Es esmu izlasījis un piekrītu privātuma politikai</a>
          </label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Apstiprināt</button>
      </form>
</div>

</body>

</html>

Share this post


Link to post
Share on other sites
Just now, Treaktors said:

izlaboju bet nav vienalga

DB.jpg

datubāzi veidoju pēc šāda

 CREATE TABLE IF NOT EXISTS `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `active` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
)

Share this post


Link to post
Share on other sites

Kā tu izlaboji? Patreiz izskatās, ka isset rezultāts, boolean, tiek ierakstīts datubāzē un konvertēts uz text reprezentāciju, kas būtu "1".

Share this post


Link to post
Share on other sites
5 minutes ago, daGrevis said:

Kā tu izlaboji? Patreiz izskatās, ka isset rezultāts, boolean, tiek ierakstīts datubāzē un konvertēts uz text reprezentāciju, kas būtu "1".

''text'' nomainīju uz ''email''

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...