ianhaney50
Members-
Posts
261 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ianhaney50
-
ahh maybe not, the record is duplicating in the database
-
sorted it, in the database under indexes, username and email was set to UNIQUE so just changed it to INDEX and now works perfect and adds the data to the database and the image location is uploaded on the database and the actual image is added into the folder on the server and redirects to the login.php?msg=Registered Successfully now so all is good
-
I have put the coding in for the header location just above and its still not redirecting and yeah I am deleting the inserted row and then signing up again but still getting the following on the php page Form has been submitted successfully. The file new-logo.jpg has been uploaded, and your information has been added to the directory MySQL error no 1062 : Duplicate entry 'ianhaney' for key 'username'
-
how can I fix the issue on the username within the database? ahh should I use header location instead, is that it? was trying to remember off top of my head
-
Ahh cool, thank you so much, have corrected them issues now and works perfect and only got one little one now on the php page it comes up with the following Form has been submitted successfully. The file new-logo.jpg has been uploaded, and your information has been added to the directory MySQL error no 1062 : Duplicate entry 'ianhaney' for key 'username' <---- NOT SURE WHAT IS CAUSING THIS ERROR Also after submitting the form it should redirect to login.php with the following url redirect_to("login.php?msg=Registered successfully"); but is just staying on register.php page with the message I pasted above with the MySQL error no 1062
-
Hi I am building a sign up form with image upload as I do know is better to store the images on the server within a folder and just store the image filepath within the database so that's what I have done and seems to be working and not at the same time I created a user and it has registered successfully with all the data and has stored the image itself in the uploads folder on the server and in the database it has stored the image filepath but am getting the following errors on the register.php page Notice: Undefined variable: error in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/directory-site/register.php on line 25 Form has been submitted successfully. Notice: Undefined index: uploadedfile in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/directory-site/register.php on line 84 The file has been uploaded, and your information has been added to the directory MySQL error no 1062 : Duplicate entry 'ianhaney' for key 'username' The coding is below <?php if (isset($_POST['submit']) && $error == '') { // if there is no error, then process further echo "<p class='success'>Form has been submitted successfully.</p>"; // showing success message ## connect mysql server $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); # check connection if ($mysqli->connect_errno) { echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>"; exit(); } //This is the directory where images will be saved $target = "uploads/"; $target = $target . basename( $_FILES['photo']['name']); ## query database # prepare data for insertion $username = mysqli_real_escape_string($mysqli, $_POST['username']); $password = md5($_POST['password']); $companyname = mysqli_real_escape_string($mysqli, $_POST['companyname']); $email = mysqli_real_escape_string($mysqli, $_POST['email']); $address1 = mysqli_real_escape_string($mysqli, $_POST['address1']); $address2 = mysqli_real_escape_string($mysqli, $_POST['address2']); $town = mysqli_real_escape_string($mysqli, $_POST['town']); $county = mysqli_real_escape_string($mysqli, $_POST['county']); $postcode = mysqli_real_escape_string($mysqli, $_POST['postcode']); $telnumber = mysqli_real_escape_string($mysqli, $_POST['telnumber']); $category = mysqli_real_escape_string($mysqli, $_POST['category']); $pic = ($_FILES['photo']['name']); # check if username and email exist else insert // u = username, e = emai, ue = both username and email already exists $exists = ""; $result = $mysqli->query("SELECT username from users WHERE username = '{$username}' LIMIT 1"); if ($result->num_rows == 1) { $exists .= "u"; } $result = $mysqli->query("SELECT email from users WHERE email = '{$email}' LIMIT 1"); if ($result->num_rows == 1) { $exists .= "e"; } if ($exists == "u") echo "<p><b>Error:</b> Username already exists!</p>"; else if ($exists == "e") echo "<p><b>Error:</b> Email already exists!</p>"; else if ($exists == "ue") echo "<p><b>Error:</b> Username and Email already exists!</p>"; else { # insert data into mysql database $sql = "INSERT INTO `users` (`id`, `username`, `password`, `companyname`, `email`, `address1`, `address2`, `town`, `county`, `postcode`, `telnumber`, `category`, `photo`) VALUES (NULL, '{$username}', '{$password}', '{$companyname}', '{$email}', '{$address1}', '{$address2}', '{$town}', '{$county}', '{$postcode}', '{$telnumber}', '{$category}', '{$pic}')"; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } $result = $mysqli->query($sql); if ($mysqli->query($sql)) { $to = $_POST['email']; $subject = "Add Listing Confirmation and Login Credentials"; $message = "Thank you for signing up and adding your listing, your login information is below \r\n Username: {$_POST['username']} \r\n Password: {$_POST['password']}"; $header = "From:noreply@domain.co.uk \r\n"; $retval = mail ($to,$subject,$message,$header); if( $retval == true ) { echo "Message sent successfully..."; } else { echo "Message could not be sent..."; } redirect_to("login.php?msg=Registered successfully"); } else { echo "<p>MySQL error no {$mysqli->errno} : {$mysqli->error}</p>"; exit(); } } } ?> <div id="column-whole"> <!-- The HTML registration form --> <form method="post" action="<?=$_SERVER['PHP_SELF']?>" enctype="multipart/form-data"> <label>Username:</label> <input type="text" name="username" required="required" placeholder="Please Enter your chosen username"/> <br /> <label>Password:</label> <input type="password" name="password" required="required" placeholder="Please Enter your chosen password"/> <br /> <label>Company Name:</label> <input type="text" name="companyname" required="required" placeholder="Please Enter your company name"> <br /> <label>Email:</label> <input type="email" name="email" required="required" placeholder="Please Enter your email"/> <br /> <label>Address Line 1:</label> <input type="text" name="address1" required="required" placeholder="Please Enter the first line of your address"/> <br /> <label>Address Line 2:</label> <input type="text" name="address2" required="required" placeholder="Please Enter the second line of your address"/> <br /> <label>Town:</label> <input type="text" name="town" required="required" placeholder="Please Enter your town"/> <br /> <label>County:</label> <input type="text" name="county" required="required" placeholder="Please Enter your county"/> <br /> <label>Postcode:</label> <input type="text" name="postcode" required="required" placeholder="Please Enter your postcode"/> <br /> <label>Telephone Number:</label> <input type="text" name="telnumber" required="required" placeholder="Please Enter your landline number"/> <br /> <label>Category:</label> <input type="text" name="category" required="required" placeholder="Please Enter your chosen category"/> <br><br> <label>Upload Image: </label> <input type="hidden" name="size" value="350000"> <input type="file" name="photo"> <br /><br /> <div class="box"> <label>I agree to the <a href="#" target="_blank">terms</a></label> </div> <input type="checkbox" class="checkbox" id="the-terms" value="I Agree"> <input type="submit" name="submit" value="Register" disabled="disabled" id="submitBtn" /> <a class="haveaccount" href="login.php">I already have an account...</a> </form> Am confused about the errors as does seem to be working sort of
-
Sorry think I got the mobnumber being retrieved from the database by the following $mobnumber = $row['mobnumber']; so now when I do var_dump($mobnumber) it displays the mobnumber on the php page so just wondering why the SMS is not sending? the updated code is below $db = mysqli_connect("" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } else { /*SUCCESS MSG*/ echo 'SUCCESS'; } $sqlCommand = "SELECT u.id , name , mobnumber , item.description , renewal_id , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue , renewal_date FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY AND IFNULL(date_notified, '1901-01-01') < CURDATE()-INTERVAL 14 DAY UNION SELECT u.id , name , mobnumber , item.description , renewal_id , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue , renewal_date FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 7 DAY AND IFNULL(date_notified, '1901-01-01') < CURDATE()-INTERVAL 7 DAY ORDER BY id, renewal_date"; $query = mysqli_query($db, $sqlCommand) or die (mysqli_error($db)); /*$mobnumber = ""; if(isset($_GET['mobnumber'])){ $mobnumber = $_GET['mobnumber']; }*/ //fetch the data from the database while ($row = mysqli_fetch_array($query)) { $originator = 'Tax Elephants'; $mobnumber = $row['mobnumber']; /*$name = '';*/ $name = $row['name']; /*if(isset($_POST['name'])){ $name = $_POST['name']; }*/ $message = $name."Name:".$row['name'].$row['description'].$row['datedue']; } // Simple SMS send function function sendSMS($username, $password, $mobnumber, $message, $originator) { $URL = 'http://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; $URL .= "&to=$to&message=".urlencode($message).'&orig='.urlencode($originator); $fp = fopen($URL, 'r'); return fread($fp, 1024); // Example of use $response = sendSMS('username', 'password', "{$row["mobnumber"]}", "{$row["description"]} expiry date: {$row["datedue"]}", "{$row["description"]} expiry date: {$row["datedue"]}"); echo $response; } var_dump($message)
-
I think it is struggling to retrieve the mobnumber from the database as done a var_dump($mobnumber) and just outputs the following The code is below $mobnumber = ""; if(isset($_GET['mobnumber'])){ $mobnumber = $_GET['mobnumber']; } //fetch the data from the database while ($row = mysqli_fetch_array($query)) { $originator = 'Tax Elephants'; $to = 'mobnumber'; $name = ''; if(isset($_POST['name'])){ $name = $_POST['name']; } $message = $name."Name:".$row['name'].$row['description'].$row['datedue']; } // Simple SMS send function function sendSMS($username, $password, $to, $message, $originator) { $URL = 'http://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; $URL .= "&to=$to&message=".urlencode($message).'&orig='.urlencode($originator); $fp = fopen($URL, 'r'); return fread($fp, 1024); // Example of use $response = sendSMS('username', 'password', "{$row["mobnumber"]}", "{$row["description"]} expiry date: {$row["datedue"]}", "{$row["description"]} expiry date: {$row["datedue"]}"); echo $response; } var_dump($mobnumber)
-
Just a update, I have done a var_dump($message) and outputs the following data so is connected to the database and getting the correct data, is just the SMS is not sending string(29) "Name:Ian HaneyTax10 July 2015" // Simple SMS send function function sendSMS($username, $password, $to, $message, $message) { $URL = 'http://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; $URL .= "&to=$to&message=".urlencode($message).'&orig='.urlencode($message); $fp = fopen($URL, 'r'); return fread($fp, 1024); // Example of use $response = sendSMS('username', 'password', $mobnumber, "{$row["description"]} expiry date: {$row["datedue"]}", "{$row["description"]} expiry date: {$row["datedue"]}"); echo $response; }
-
Ahh just moved a } to below the last of the PHP and the error has gone and just got a success message from where it is connected to the database <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <html> <title>Automatic SMS Text</title> <body> <?php $db = mysqli_connect("" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } else { /*SUCCESS MSG*/ echo 'SUCCESS'; } $sqlCommand = "SELECT u.id , name , mobnumber , item.description , renewal_id , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue , renewal_date FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY AND IFNULL(date_notified, '1901-01-01') < CURDATE()-INTERVAL 14 DAY UNION SELECT u.id , name , mobnumber , item.description , renewal_id , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue , renewal_date FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 7 DAY AND IFNULL(date_notified, '1901-01-01') < CURDATE()-INTERVAL 7 DAY ORDER BY id, renewal_date"; $query = mysqli_query($db, $sqlCommand) or die (mysqli_error($db)); $mobnumber = ""; if(isset($_GET['mobnumber'])){ $mobnumber = $_GET['mobnumber']; } //fetch the data from the database while ($row = mysqli_fetch_array($query)) { $to = $mobnumber; $name = ''; if(isset($_POST['name'])){ $name = $_POST['name']; } $message = $name."Name:".$row['name'].$row['description'].$row['datedue']; } // Simple SMS send function function sendSMS($username, $password, $to, $message, $originator) { $URL = 'http://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; $URL .= "&to=$to&message=".urlencode($message).'&orig='.urlencode($originator); $fp = fopen($URL, 'r'); return fread($fp, 1024); // Example of use $response = sendSMS('', '', '447538503276', 'test message', 'test message 1'); /*$response = sendSMS("47799", "692px", "{$mobnumber}", "{$row['description']} expiry date: {$row['datedue']}", "{$row['description']} expiry date: {$row['datedue']}");*/ echo $response; } ?> </body> </html> I was hoping I would receive a text on my mobile number but nothing has came through
-
I changed that line to the following $response = sendSMS("username", "password", "{$mobnumber}", "{$row['description']} expiry date: {$row['datedue']}", "{$row['description']} expiry date: {$row['datedue']}"); I get the following error with that invalid number or not an integer
-
spose in a way will be a single SMS to each individual signed up user when their dates are due to expire within 14 and 7 days I have taken out the $current_visitor parts now
-
Hi I am building a SMS coding script that does the same for my auto email script that pings a email out to signed up users if their expiry date is within 14 and 7 days and I set up a cron job to check it every day and now am building a SMS script to do the same so it sends a SMS text out to the signed up users, I am using text marketer and all they said was it is possible with their system and said to build a script and put the system into it so have put together the following coding and on the php page it is just saying SUCCESS so looks like it has connected to the database successfully but just seeing if anyone would mind just checking over the coding to see if I have missed anything please <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php $db = mysqli_connect("" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } else { /*SUCCESS MSG*/ echo 'SUCCESS'; } $sqlCommand = "SELECT u.id , name , mobnumber , item.description , renewal_id , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue , renewal_date FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY AND IFNULL(date_notified, '1901-01-01') < CURDATE()-INTERVAL 14 DAY UNION SELECT u.id , name , mobnumber , item.description , renewal_id , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue , renewal_date FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 7 DAY AND IFNULL(date_notified, '1901-01-01') < CURDATE()-INTERVAL 7 DAY ORDER BY id, renewal_date"; $query = mysqli_query($db, $sqlCommand) or die (mysqli_error($db)); $current_visitor=0; $mobnumber = ""; if(isset($_GET['mobnumber'])){ $mobnumber = $_GET['mobnumber']; } //fetch the data from the database while ($row = mysqli_fetch_array($query)) { $to = $mobnumber; $name = ''; if(isset($_POST['name'])){ $name = $_POST['name']; } $message = $name."Name:".$row['name'].$row['description'].$row['datedue']; if ($row['id'] != $current_visitor) { if ($current_visitor != 0) { $to = $mobnumber; $current_visitor = $row['id']; // Simple SMS send function function sendSMS($username, $password, $to, $message, $originator) { $URL = 'http://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; $URL .= "&to=$to&message=".urlencode($message).'&orig='.urlencode($originator); $fp = fopen($URL, 'r'); return fread($fp, 1024); } // Example of use $response = sendSMS('textmarketerusername', 'textmarketerpassword', '{$mobnumber}', '{$row["description"]} expiry date: {$row["datedue"]}', '{$row["description"]} expiry date: {$row["datedue"]}'); echo $response; } } } ?> Thank you in advance
-
Ahh thank you so much, I took the link out now to the script.js that was causing it and is loads quicker, thank you again so much
-
Hi scootstah sorry yeah is live, the link is below http://www.broadwaymediadesigns.co.uk/sites/the-tax-elephants/register.php The only javascript is at the end after the form that disables the submit button until the check the checkbox, the html and javascript is below <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <label>Username:</label> <input type="text" name="username" required="required" placeholder="Please Enter your chosen username"/> <br /> <label>Password:</label> <input type="password" name="password" required="required" placeholder="Please Enter your chosen password"/> <br /> <label>Name:</label> <input type="text" name="name" required="required" placeholder="Please Enter your name"> <br /> <label>Email:</label> <input type="email" name="email" required="required" placeholder="Please Enter your email"/> <br /> <label>Address Line 1:</label> <input type="text" name="address1" required="required" placeholder="Please Enter the first line of your address"/> <br /> <label>Address Line 2:</label> <input type="text" name="address2" required="required" placeholder="Please Enter the second line of your address"/> <br /> <label>Town:</label> <input type="text" name="town" required="required" placeholder="Please Enter your town"/> <br /> <label>County:</label> <input type="text" name="county" required="required" placeholder="Please Enter your county"/> <br /> <label>Postcode:</label> <input type="text" name="postcode" required="required" placeholder="Please Enter your postcode"/> <br /> <label>Telephone Number:</label> <input type="text" name="telnumber" required="required" placeholder="Please Enter your landline number"/> <br /> <label>Mobile Number:</label> <input type="text" name="mobnumber" required="required" placeholder="Please Enter your mobile number"/> <br /> <label>Car/Van Model:</label> <input type="text" name="model" required="required" placeholder="Please Enter your car/van model"/> <br /> <label>Car/Van Number Plate:</label> <input type="text" name="numplate" required="required" placeholder="Please Enter your car/number plate"/> <br /> <label>Car Tax Renewal Date :</label> <input type="text" id="datepicker" name="tax" required="required" placeholder="Please Enter your Car Tax Renewal Date"/> <br> <label>MOT Expiry Date :</label> <input type="text" id="datepicker2" name="mot" required="required" placeholder="Please Enter your MOT Expiry Date"/> <br /> <label>Insurance Expiry Date :</label> <input type="text" id="datepicker3" name="insurance" required="required" placeholder="Please Enter your Insurance Expiry Date"/> <br><br> <div class="box"> <label>I agree to the <a href="#popup1">terms</a></label> </div> <input type="checkbox" class="checkbox" id="the-terms" value="I Agree"> <div id="popup1" class="overlay"> <div class="popup"> <h2>Terms</h2> <a class="close" href="#">×</a> <div class="content"> TERMS TEXT. </div> </div> </div> <input type="submit" name="submit" value="Register" disabled="disabled" id="submitBtn" /> <a class="haveaccount" href="login.php">I already have an account...</a> </form> </div> <!--CONTENT--> <script> $(document).ready(function() { var the_terms = $("#the-terms"); the_terms.click(function() { if ($(this).is(":checked")) { $("#submitBtn").removeAttr("disabled"); } else { $("#submitBtn").attr("disabled", "disabled"); } }); }); </script>
-
Sorry sussed it out
-
Hi Sorry def the last issue, just testing the edit profile php to make sure is all ok still and I noticed if I edit the number plate for example it updates for the user I am logged in as but if I edit the car tax date for example it is updating it but not for the user I am logged in as, for example I am logged in as id=24 and updating the car tax date for that id but the car tax date is updating for id=23 for some reason, not sure why it is doing that, the code I have is below on the edit-data.php file <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); require_once("functions.php"); require_once("db-const.php"); include 'includes/header.php'; if (logged_in() == false) { redirect_to("login.php"); exit; } else { if (isset($_GET['id']) && $_GET['id'] != "") { $id = $_GET['id']; } else { $id = $_SESSION['user_id']; } $db = mysqli_connect("" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } } // Prepared statements are better, but at least escape things before tossing them into a query $id = mysqli_real_escape_string($db, $id); $name = mysqli_real_escape_string($db, $_POST['name']); $email = mysqli_real_escape_string($db, $_POST['email']); $address1 = mysqli_real_escape_string($db, $_POST['address1']); $address2 = mysqli_real_escape_string($db, $_POST['address2']); $town = mysqli_real_escape_string($db, $_POST['town']); $county = mysqli_real_escape_string($db, $_POST['county']); $postcode = mysqli_real_escape_string($db, $_POST['postcode']); $telnumber = mysqli_real_escape_string($db, $_POST['telnumber']); $mobnumber = mysqli_real_escape_string($db, $_POST['mobnumber']); $model = mysqli_real_escape_string($db, $_POST['model']); $numplate = mysqli_real_escape_string($db, $_POST['numplate']); $sql1 = "UPDATE users SET name='$name', email='$email', address1='$address1', address2='$address2', town='$town', county='$county', postcode='$postcode', telnumber='$telnumber', mobnumber='$mobnumber', model='$model', numplate='$numplate' WHERE id='$id';"; $query1 = mysqli_query($db, $sql1) or die (mysqli_error($db)); $tax = ($_POST['tax']); $mot = ($_POST['mot']); $insurance = ($_POST['insurance']); $insurance = date('Y-m-d', strtotime($_POST['insurance'])); $mot = date('Y-m-d', strtotime($_POST['mot'])); $tax = date('Y-m-d', strtotime($_POST['tax'])); $sql2 = "UPDATE renewal SET renewal_date='$insurance' WHERE item_id=1 LIMIT 1;"; $query2 = mysqli_query($db, $sql2) or die (mysqli_error($db)); $sql3 = "UPDATE renewal SET renewal_date='$mot' WHERE item_id=2 LIMIT 1;"; $query3 = mysqli_query($db, $sql3) or die (mysqli_error($db)); $sql4 = "UPDATE renewal SET renewal_date='$tax' WHERE item_id=3 LIMIT 1;"; $query4 = mysqli_query($db, $sql4) or die (mysqli_error($db)); header("location:profile.php?id={$_SESSION['user_id']}"); ?> <?php include 'includes/footer.php'; ?>
-
Sorry sorted this issue I forgot to have WHERE clause in on the SELECT
-
Hi I just came across one little issue, hopefully is the last one as all the rest is perfect, on my profile.php it seems to be displaying everyones data and not just the data of the user I am logged in as, the coding is below from the profile.php file <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php require_once("functions.php"); require_once("db-const.php"); ?> <?php $title = "My Account Profile - The Tax Elephants"; $pgDesc=""; $pgKeywords=""; include ( 'includes/header.php' ); ?> <!--CONTENT--> <div id="column-whole"> <div class="features"> <?php if (logged_in() == false) { redirect_to("login.php"); } else { if (isset($_GET['id']) && $_GET['id'] != "") { $id = $_GET['id']; } else { $id = $_SESSION['user_id']; } $db = mysqli_connect("" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } else { echo ''; } ## query database # fetch data from mysql database $sql = "SELECT u.id , name , email , address1 , address2 , town , county , postcode , telnumber , mobnumber , model , numplate , item.description , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) ORDER BY u.id, renewal_date;"; $query = mysqli_query($db, $sql) or die (mysqli_error($db)); $prev_id = 0; //fetch the data from the database while ($row = mysqli_fetch_array($query)) { // if the vistor id does not equal the vistor id from previous row, // output vistor id, name and email only once if($row['id'] != $prev_id) { echo "Name: " . $row ['name']; echo "<br>"; echo "Email: " . $row ['email']; echo "<br>"; echo "First line of address: " . $row ['address1']; echo "<br>"; echo "Second line of address: " . $row ['address2']; echo "<br>"; echo "Town: " . $row ['town']; echo "<br>"; echo "County: " . $row ['county']; echo "<br>"; echo "Postcode: " . $row ['postcode']; echo "<br>"; echo "Telephone Number: " . $row ['telnumber']; echo "<br>"; echo "Mobile Number: " . $row ['mobnumber']; echo "<br>"; echo "Model of car: " . $row ['model']; echo "<br>"; echo "Car Number Plate: " . $row ['numplate']; } // output the reneweal dates echo "<br>"; echo $row ['description'] . " expiry date: " . $row['datedue'] . "\n"; // set current rows vistor id to previous id $prev_id = $row['id']; } echo "<br><br>"; echo "<a href='edit-profile.php?id={$_SESSION['user_id']}'>Edit Information</a>"; } // Free the results mysqli_free_result($query); //close the connection mysqli_close($db); ?> </div> </div> <!--CONTENT--> <?php include( 'includes/footer.php' ); ?>
-
Hi I just built a web project and all works perfect but noticed when typing in any of the forms like login, register, or update the profile form, typing is really slow and lags in the form has this happened to anyone else as not sure what is causing it?
-
Sorry got is sussed and working now
-
sorry got a update now I added session_start() in as I forgot to include it the edit-page.php now outputs the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(r.renewal_date, '%e %M %Y') AS renewal, i.description users AS u ' at line 2 below is the whole code <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); require_once("functions.php"); require_once("db-const.php"); include 'includes/header.php'; if (logged_in() == false) { redirect_to("login.php"); exit; } else { if (isset($_GET['id']) && $_GET['id'] != "") { $id = $_GET['id']; } else { $id = $_SESSION['user_id']; } $db = mysqli_connect("176.32.230.22" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } } // Prepared statements are better, but at least escape things before tossing them into a query $id = mysqli_real_escape_string($db, $id); $sql = "UPDATE u.id, u.name, u.email, u.address1, u.address2, u.town, u.county, u.postcode, u.telnumber, u.mobnumber, u.model, u.numplate, DATE_FORMAT(r.renewal_date, '%e %M %Y') AS renewal, i.description users AS u INNER JOIN renewal AS r ON u.id = r.id INNER JOIN item AS i on r.item_id = i.item_id WHERE u.id= {$id}"; $query = mysqli_query($db, $sql) or die (mysqli_error($db)); header("location:profile.php?id={$_SESSION['user_id']}"); ?>
-
I am trying to update the info now and when I click update on the form, it is not updating still and redirects to profile.php instead of profile.php?id={$_SESSION['user_id']} <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); require_once("functions.php"); require_once("db-const.php"); if (logged_in() == false) { redirect_to("login.php"); exit; } else { if (isset($_GET['id']) && $_GET['id'] != "") { $id = $_GET['id']; } else { $id = $_SESSION['user_id']; } $db = mysqli_connect("" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } } // Prepared statements are better, but at least escape things before tossing them into a query $id = mysqli_real_escape_string($db, $id); $sql = "UPDATE u.id, u.name, u.email, u.address1, u.address2, u.town, u.county, u.postcode, u.telnumber, u.mobnumber, u.model, u.numplate, DATE_FORMAT(r.renewal_date, '%e %M %Y') AS renewal, i.description users AS u INNER JOIN renewal AS r ON u.id = r.id INNER JOIN item AS i on r.item_id = i.item_id WHERE u.id= {$id}"; $query = mysqli_query($db, $sql) or die (mysqli_error($db)); header("location:profile.php?id={$_SESSION['user_id']}"); ?>
-
I now changed it to the following <label>Car Tax Renewal Date :</label> <input type="text" id="datepicker" name="tax" required="required" placeholder="Please Enter your Car Tax Renewal Date" value="<?php echo $row['tax'];?>" /> <br /><br /> <label>MOT Renewal Date :</label> <input type="text" id="datepicker2" name="mot" required="required" placeholder="Please Enter your Car MOT Renewal Date" value="<?php echo $row['mot'];?>" /> <br /><br /> <label>Insurance Renewal Date :</label> <input type="text" id="datepicker3" name="insurance" required="required" placeholder="Please Enter your Car Insurance Renewal Date" value="<?php echo $row['insurance'];?>" /> that gives me the following error Notice: Undefined index: tax in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 128 I got the following in, if I change datedue on them lines to the individual ones so insurance, tax, mot, I get more errors $insurance = $row['datedue']; $tax = $row['datedue']; $mot = $row['datedue']; so it becomes $insurance = $row['insurance']; $tax = $row['tax']; $mot = $row['mot']; the errors I get then are below Notice: Undefined index: insurance in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 85 Notice: Undefined index: tax in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 86 Notice: Undefined index: mot in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 87
-
I have noticed one issue as well, it's the dates are being outputted the same, the coding is in the following pastebin link http://pastebin.com/8iTenNmM I took the loop out, well think I have Is it ok to check the coding?