Jump to content

ezeuba

Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

ezeuba's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Good day all. I am trying to achieve entering multiple email addresses to a mysql database field all at once. I wrote the following script to manage this but it's not working. I am seperating the emails with comma, but it only enters this (') into the database. I am trying to use implode function but I don't seem to be getting it right. Any help will be appreciated. Here is the code: <?php if(isset($_POST['submit'])){ $email = $_POST['email']; if(empty($email)) { echo '<p><font color="red"><strong>NO EMAIL ADDRESSES ENTERED</strong></font></p>'; $badinput = '<p><font color="red"><strong>PLEASE INPUT MEMBERS' EMAIL ADDRESSES</strong></font></p>'; echo $badinput; } else{ mysql_connect("somehost","someadmin","somepassword");//database connection mysql_select_db("somedatabase"); //inserting data order $allemails="('".implode("'), ('",$email)."')"; $membersemail = "INSERT INTO sometable (email) VALUES ('$allemails')"; //declare in the order variable $result = mysql_query($membersemail); //$membersemail executes } if($result){ echo '<center><font color="red"><h1>SUCCESS!!!</h1></font></center>'; echo '<center><h3>DATABASE POPULATED WITH MEMBERS' EMAIL ADDRESSES</h3></center>'; } } ?> <form name= "someform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <center><table border="0" cellspacing="10"> <tbody> <tr> <td align="right"><span class="style5">Members' E-mail Addresses:</span> </td> <td><label for="email"></label> <textarea name="email" id="email" cols="45" rows="10"></textarea> </td> </tr> </tbody></table> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"></center> </form> What am I doing wrong? Thanks all.
  2. Good day all, I have this change password code and it works well when all the parameters are ok, like username correct and email correct. But when I test it to see the result if the wrong username or email is entered the else statement doesnt run, not even an error, just skips the code and shows the other parts of the page, just as if the code did not run. Here is the code: <?php include("mysql_connect.php"); $username=$_POST['username']; $email=$_POST['email']; $newpassword=$_POST['newpassword']; $confirm_newpassword=$_POST['confirm_newpassword']; $query = "SELECT * FROM users WHERE username='$username' AND email='$email'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ if ($username == $row["username"] && $email == $row["email"]){ echo "<center><h1>Thank you " . $row["firstname"] ." ". $row["surname"] .". Your password has been changed.<br/> An email has also been sent to $email with the details of the new password.</h1></center>"; $sql="UPDATE users SET password = '$newpassword', password_confirm='$confirm_newpassword' WHERE (id = $row[id])"; $update = mysql_query($sql) or die(mysql_error()); $to = $row["email"]; $subject = "Your password change at My Site"; $message = "Dear " . $row["firstname"] ." ". $row["surname"] .",\r\rYour Password Change has been completed successfully.\r\rYour New Password is:\r". $row["password"] .".\r\rPlease guard this Password carefully.\r\rRegards,\rAdmin - My Site"; require_once "class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSendmail(); $mail->SetFrom('admin@mysite.com', 'Admin - My Site'); $mail->AddAddress($to); $mail->Subject = $subject; $mail->Body = $message; $mail->Send(); } else{ echo"<center><h1>Invalid username and/or email.<br/>Please go back to the <a href=\"password_recovery.php\">Password Change Request</a> page and enter correct details.</h1></center>"; } } ?>
  3. Good day all. I am very new to this php-mysql language, having come from using frontpage as my designer. I recently switched to dreamweaver after hearing folks sing its praise. I am now building a website with mysql database which I have already created, having used phpmyadmin(great tool), I have also layed out my pages but my problem is getting the login and data display pages to work. The data insertion works like a breeze, but I cannot seem to get the right way to get deamweaver setup these other pages correctly, because I want to use a username and password criteria to display data from the mysql database when user logs in, and only his data, hence the username and password criteria. The most I can get from dreamweaver is to use only password, via the recordset. When I try advanced mode it crashes because I cannot get the parameters correct. I used to do this fine and well with frontpage and access database. I wonder if I shouldn't go back to frontpage and access, it served my purpose only that I want to try new technologies in webdesign. I would appreciate any and all help anyone can render towards solving this problem. In a nutshell I need to display user data when he logs in with his username and password. Thank you all.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.