-
Posts
439 -
Joined
-
Last visited
Posts posted by I-AM-OBODO
-
-
Thanks guys. It now working
-
Mysql uses yyyy-mm-dd format.
You need to convert your calendar dates to that for mat for comparisons
$ymd = date('Y-m-d', strtotime($calendardate));
Thanks. It's working now
-
Hi all.
In my code I use MySQL curdate() and now() to insert the current date and time in my db. and to get the date and time output I used a calender script I found on internet. the calendar inputs date in the format 12/10/2020 and MySQL date and time format is different (which I believe that's why my script isnt working)
I did a select * from table_name where user is boy and date between $start and $end
but all I'm getting is blank page. I think I need to conver my form date to something MySQL will understand before I can get an output but I don't know how?
how can I achive a result
thanks
-
Hi all. I am currently doing something like a banking project for myself. I am wondering if there is a way I can use a jQuery loader meter to indicate the transfer process so that when a user clicks on transfer, the meter will popup and be reading and when it gets to 100% shows transfer complete. Hope I'm clear enough.
Thanks
-
thanks but mysql_fetch_assoc didn't get the job done, it still brought out resource error.
but mysql_fetch_object did the magic
pls is there a better way of getting same objective? cos I feel my code is too amateurish and security loophole
thanks
-
Good day guys.
Pls I'm stuck here. I am trying to design a payment platform. It's a project for my self. Users have to register and have money in their account just like bank. Users can transfer money from their account to another account. I'm having a problem verifying the sender's balance. The script is to check the senders balance to know if he has enough money to complete the transaction, if yes continues transaction and if no, gets an error message. My problem is that even if the balance is enough. It keeps bringing out error message "not enough money to perform transactions". Pls what am I doing wrong.
Ps. My code might appear amateurish though. I wouldn't mind to know the best way to achieve a better result putting security into consideration
Thanks
<?php $sender = $_POST['sender']; $reciever = $_POST['reciever']; $amount = $_POST['amount']; $remarks = $_POST['remarks']; if($reciever ==''){ echo "<font color=red size=3>Reciever Field Empty</font><br>"; // verify that reciever's field not empty } if($reciever == $sender){ echo "<font color=red size=3>You can't transfer to same account</font><br>"; // verify the account is not the same } if($amount ==''){ echo('<font color=red size=3>Amount Field Empty</font><br>');// verify that amount field is not empty } else{ // verify if receivers account is in database $query = "SELECT Account_No FROM reg_users WHERE Account_No='$reciever'"; $query_result = mysql_query($query) or die(mysql_error()); $count=mysql_num_rows($query_result); if($count==0){ echo "Invalid Account. Check and retry later<br>"; }else{ // verify if the sender has enough balance to perform transaction $check = "SELECT Avail_bal FROM reg_users WHERE Account_No='$sender'"; $check_result = mysql_query($check) or die(mysql_error()); if( $check_result < $amount){ echo "You don't have enough balance to complete this transaction"; // if sender dont have enough balance to make transfer }else{ // if sender has enough balance, credit reciever $update = "UPDATE reg_users SET Avail_bal = '$amount' + Avail_bal WHERE Account_No = '$reciever'"; $query_update = mysql_query($update) or die(mysql_error()); if($query_update) echo "Transfer Completed" ; else{ echo "Something went wrong"; } } } } ?> [code]
-
How do I become a better programmer? I can write codes to an extent and can read/modify codes very well, but I find it difficult to write some code from scratch. I just google and get a code and modify to my taste and I feel its killing my ability. I want to become a better programmer and so what can or should I do? Help pls
-
thanks guys
-
echo "<a href='edit.php?id={$row['id']}'> edit</a>"; // this is the edit link that should be linked to the rows
Also, note that your code is colored wrong, you have an errant double quote in your second echo inside the loop.
You're also going to have to actually write an edit page.
thanks. but what's the right way for my coloring?
-
hi all.
how can i link each row so that when i click the edit, it takes me to a new page where i can edit the row associated with the edit link?
thanks in advance.
my code
<?php $result = mysql_query("SELECT * FROM domain_info") or die(mysql_error()); echo "<table border='0' cellspacing='2' cellpadding='2'>"; echo "<tr> <th bgcolor='#0cc' align='center'><font color='#fff'>Id</th> <th bgcolor='#0cc' align='center'><font color='#fff'>Clients' Name</font></th> <th bgcolor='#0cc' align='center'><font color='#fff'>Domain Name</th> <th bgcolor='#0cc' align='center'><font color='#fff'>Size</th><th bgcolor='#0cc' align='center'><font color='#fff'>Cost</th><th bgcolor='#0cc' align='center'><font color='#fff'>Created Date</th><th bgcolor='#0cc' align='center'><font color='#fff'>Last Renew</th><th bgcolor='#0cc' align='center'><font color='#fff'>Expiry Date</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td width='25'>"; echo "$row['id']; echo "</td><td width='150'>"; echo $row['client']; echo "</td><td width='250'>"; echo $row['domain_name']; echo "</td><td width='50'>"; echo $row['size']; echo "</td><td width='50'>"; echo $row['cost']; echo "</td><td width='100'>"; echo $row['create_date']; echo "</td><td width='100'>"; echo $row['last_renewed']; echo "</td><td width='100'>"; echo $row['expiry_date']; echo "</td><td width='100'>"; echo "<a href='www.dis.com'> edit</a>"; // this is the edit link that should be linked to the rows echo "</td></tr>"; } echo "</table>"; ?>
-
$parola .= $my_array[$random];
That line is the same as $parola = $parola . $my_array[$random]; which means it is trying to first read the existing value of $parola before setting it to the new value. On your very first iteration of the loop, $parola does not exist because you've never defined it anywhere. Because it does not exist when php tries to read it you receive that notice.
Add $parola = ''; before your loop to define the variable first.
thanks. its okay now. had to define parola before the functions
-
hi all,
pls I dont know why am getting this error undefined variable: parola. but the script runs
thanks
<?php $my_array = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "0", "1", "2", "3", "4", "5"); for ($i=0; $i<=5; $i++) { $random = array_rand($my_array); //this generates the random number from the array $parola .= $my_array[$random]; //here we will display the exact charachter from the array } echo $parola; // printing result ?>
-
This is what i have done so far, but two problems;
1, the last number is duplicated
2, how can i make the numbers come in pair of three (12, 16, 18)
thank you
form
<form id="form1" name="form1" method="post" action="show.php"> <table width="100%" border="0" cellspacing="2" cellpadding="1"> <tr> <td width="21%">Input Numbers : </td> <td width="79%"><input name="one" type="text" id="one" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="two" type="text" id="two" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="three" type="text" id="three" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="four" type="text" id="four" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="five" type="text" id="five" size="10" /></td> </tr> <tr> <td width="21%"> </td> <td><input name="six" type="text" id="six" size="10" /></td> </tr> <tr> <td> </td> <td><input name="seven" type="text" id="seven" size="10" /></td> </tr> <tr> <td> </td> <td><input name="eight" type="text" id="eight" size="10" /></td> </tr> <tr> <td> </td> <td><input name="nine" type="text" id="nine" size="10" /></td> </tr> <tr> <td> </td> <td><input name="ten" type="text" id="ten" size="10" /></td> </tr> <tr> <td> </td> <td><input name="generate" type="submit" id="generate" value="Generate" /></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
show.php
<?php $one = $_POST['one']; $two = $_POST['two']; $three = $_POST['three']; $four = $_POST['four']; $five = $_POST['five']; $six = $_POST['six']; $seven = $_POST['seven']; $eight = $_POST['eight']; $nine = $_POST['nine']; $ten = $_POST['ten']; $bingo = array($one,$two,$three,$four,$five,$six,$seven,$eight,$nine,$ten); shuffle($bingo); foreach ($bingo as $number) { echo "$number "; } echo $number; ?>
-
If you already have the numbers you want to pick a random from, then you could put it in an array and use shuffle and from there use the first in the array, but what is far more recommended is to instead generate a random number with mt_rand and by that number pick one at random from the array.
Example:
<?php $numbers[] = 10; $numbers[] = 5; $numbers[] = 0; $numbers[] = 7; $numbers[] = 13; $numbers[] = 9; $numbers[] = 25; $numbers[] = 4; echo $numbers[mt_rand(0,count($numbers)-1]; ?>
Thank you.
but why i am using my own number instead of generating numbers with mt_rand() is because, i want the user to be able to input their own series of numbers so that the program shuffles and bring them in pairs.
-
Hi all,
sorry cos there is no code.
please how can i generate pairs (in twos, threes, fours or five) from a given set of numbers. the numbers are to be typed in the form text field and when click generate(submit button) it brings out the pair of numbers. thanks in advance
my form
<form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="1"> <tr> <td width="21%">Input Numbers : </td> <td width="79%"><input name="numbers" type="text" id="numbers" size="50" /></td> </tr> <tr> <td> </td> <td><input name="generate" type="submit" id="generate" value="Generate" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
-
You can't have a form within a form. You can change lines within a form, for example input fields or submit as new or as an update, but nesting forms is not allowed.
but i have seen something of that sort. i am trying to model from what i saw in bamboo invoice an application built with codeigniter. whatever he used, i dont know but all i know is that when you click add button, it brings out another form field
-
Hi,
how can i create a form within a form with the click of a button? so that when i click add new item, it brings form fields under the current one. hope my explanation helps
thanks
<form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="22%">Invoice Number </td> <td width="78%"> </td> </tr> <tr> <td>Date Issued </td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="10%">Quantity</td> <td width="70%">Description</td> <td width="9%">Taxable</td> <td width="11%">Amnount</td> </tr> <tr> <td valign="top"><input name="textfield" type="text" size="7" /></td> <td valign="top"><textarea name="textfield2" cols="80"></textarea></td> <td valign="top"><input type="checkbox" name="checkbox" value="checkbox" /></td> <td valign="top"><input name="textfield3" type="text" size="12" /></td> </tr> <tr> <td colspan="4"><input type="submit" name="Submit" value="Add New Item" /></td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
-
echo "<option value ='2'>".$row"['name']</option>";
1) You've got a mis-placed double-quote in there
2) You're missing a concatenation operator
3) Having the same "value" for all of them will not be very helpful
echo "<option value ='" . $row['id'] . "'>" . $row['name'] . "</option>";
thanks. gat it now
-
Hi all,
i want my list/menu field values to come from my database. how can i accomplish that?
thanks
i did
<select name="select"> <option value="0">--select below--</option> <option value="1">Me</option> <?php require_once '../konnect/konex.php'; $result = mysql_query("SELECT * FROM is_clients"); while($row = mysql_fetch_array($result)) { echo "<option value ='2'>".$row"['name']</option>"; echo "<br />"; } ?> </select>
-
Hi all,
pls, how can i change the error message color to red?
thanks
<?php echo form_open('form'); ?> <h5>First Name:</h5> <?php echo form_error('fname'); ?> <input type="text" name="fname" value="<?php echo set_value('fname'); ?>" size="50" /> <h5>Surname:</h5> <?php echo form_error('sname'); ?> <input type="text" name="sname" value="<?php echo set_value('sname'); ?>" size="50" /> <h5>Email Address</h5> <?php echo form_error('email'); ?> <input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" /> <h5>Password</h5> <?php echo form_error('password'); ?> <input type="password" name="password" value="<?php echo set_value('password'); ?>" size="50" /> <h5>Password Confirm</h5> <?php echo form_error('passconf'); ?> <input type="password" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" /> <div><input type="submit" value="Submit" /></div> </form>
-
Hi all,
i keep getting double entry in my db. how do i stop it? guess my method is wrong. part of my code below thanks
$form_data = array( 'id' => set_value(''), 'fname' => set_value('fname'), 'sname' => set_value('sname'), 'email' => set_value('email'), 'password' => set_value('password') ); $query = $this->db->query('SELECT email FROM reg_users'); if ($query >1) { echo 'Username Already exist'; } else{ if ($this->reg_model->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db { redirect('forms/success'); // or whatever logic needs to occur }
thanks again
-
Hi
i have tried various method to get the value of current date (which is a hidden field), but in my database it just 0000000 i get. the date dont seem to be inserted. i tried declaring date as a variable in my controller file ($date = date('Y-m-d H:i:s', now()) then passed it on to the db but no avail, i also tried declaring it on the view file still no avail. Where am i going wrong? thanks in advance
My code
View
<?php // Change the css classes to suit your needs //$attributes = array('class' => '', 'id' => ''); echo form_open('services'); ?> <p> <label for="title">Title <span class="required">*</span></label> <?php echo form_error('title'); ?> <?php // Change the values in this array to populate your dropdown as required ?> <?php $options = array( '' => 'Please Select', 'mr' => 'Mr', 'mrs' => 'Mrs', 'miss' => 'Miss', 'ms' => 'Ms', 'dr' => 'Dr', 'prof' => 'Prof', 'alhaji' => 'Alhaji' ); ?> <br /><?php echo form_dropdown('title', $options, set_value('title'))?> </p> <p> <label for="surname">Surname <span class="required">*</span></label> <?php echo form_error('surname'); ?> <br /><input id="surname" type="text" name="surname" maxlength="25" value="<?php echo set_value('surname'); ?>" /> </p> <p> <label for="firstname">Firstname <span class="required">*</span></label> <?php echo form_error('firstname'); ?> <br /><input id="firstname" type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" /> </p> <p> <label for="email">Email <span class="required">*</span></label> <?php echo form_error('email'); ?> <br /><input id="email" type="text" name="email" maxlength="25" value="<?php echo set_value('email'); ?>" /> </p> <p> <label for="state">State <span class="required">*</span></label> <?php echo form_error('state'); ?> <br /><input id="state" type="text" name="state" maxlength="25" value="<?php echo set_value('state'); ?>" /> </p> <p> <label for="tel">Tel <span class="required">*</span></label> <?php echo form_error('tel'); ?> <br /><input id="tel" type="text" name="tel" maxlength="20" value="<?php echo set_value('tel'); ?>" /> </p> <p> <label for="topic">Topic <span class="required">*</span></label> <?php echo form_error('topic'); ?> <?php // Change the values in this array to populate your dropdown as required ?> <?php $options = array( '' => 'Please Select', 'paye' => 'PAYE', 'capital' => 'Capital Reconstruction', 'cash' => 'Cash Flow Forcasting', ); ?> <br /><?php echo form_dropdown('topic', $options, set_value('topic'))?> </p> <p> <label for="msg">Message <span class="required">*</span></label> <?php echo form_error('msg'); ?> <br /> <?php echo form_textarea( array( 'name' => 'msg', 'rows' => '5', 'cols' => '50', 'value' => set_value('msg') ) )?> </p> <p> <?php $date = date('Y-m-d H:i:s', now()); echo form_hidden( 'date', '$date'); ?> </p> <p> <?php echo form_submit( 'submit', 'Submit'); ?> </p> <?php echo form_close(); ?>
controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Services extends CI_Controller { public function __construct() { parent::__construct(); //$this->load->library('form_validation'); //$this->load->database(); //$this->load->helper('form'); //$this->load->helper('url'); $this->load->model('services_model'); } public function view($page = 'easylife') { if ( ! file_exists('application/views/services/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('services/'.$page, $data); $this->load->view('templates/footer', $data); } public function index() { $this->form_validation->set_rules('title', 'title', 'required|trim|xss_clean|max_length[10]'); $this->form_validation->set_rules('surname', 'surname', 'required|trim|xss_clean|max_length[25]'); $this->form_validation->set_rules('firstname', 'firstname', 'required|trim|xss_clean'); $this->form_validation->set_rules('email', 'email', 'required|trim|xss_clean|valid_email|max_length[25]'); $this->form_validation->set_rules('state', 'state', 'required|trim|xss_clean|max_length[25]'); $this->form_validation->set_rules('tel', 'tel', 'required|trim|xss_clean|is_numeric|max_length[20]'); $this->form_validation->set_rules('topic', 'topic', 'required|trim|xss_clean|max_length[25]'); $this->form_validation->set_rules('msg', 'msg', 'required|trim|xss_clean|max_length[50]'); $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>'); if ($this->form_validation->run() == FALSE) // validation hasn't been passed { //$this->load->view('advisory'); $this->load->view('templates/header'); $this->load->view('services/advisory'); $this->load->view('templates/footer'); } else // passed validation proceed to post success logic { // build array for the model $form_data = array( 'title' => set_value('title'), 'surname' => set_value('surname'), 'firstname' => set_value('firstname'), 'email' => set_value('email'), 'state' => set_value('state'), 'tel' => set_value('tel'), 'topic' => set_value('topic'), 'msg' => set_value('msg'), 'date' => set_value('date') ); // run insert model to write data to db if ($this->services_model->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db { redirect('services/success'); // or whatever logic needs to occur } else { echo 'An error occurred saving your information. Please try again later'; // Or whatever error handling is necessary } } } function success() { echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note sessions have not been used and would need to be added in to suit your app'; } } ?>
-
Hi,
i don't really know why my form isn't working, even when i click on empty, its still not validating.
Here's my code:
Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Services extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('services_model'); } public function view($page = 'easylife') { if ( ! file_exists('application/views/services/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('services/'.$page, $data); $this->load->view('templates/footer', $data); } public function advisory() { $this->load->helper('form'); $this->load->library('form_validation'); //$data['title'] = 'Create a news item'; $this->form_validation->set_rules('title', 'Title', 'required'); $this->form_validation->set_rules('sname', 'Surname', 'required'); $this->form_validation->set_rules('fname', 'First Name', 'required'); $this->form_validation->set_rules('email', 'Email', 'required'); $this->form_validation->set_rules('state', 'State', 'required'); $this->form_validation->set_rules('tel', 'telephone', 'required'); $this->form_validation->set_rules('msg', 'Message', 'required'); if ($this->form_validation->run() === FALSE) { $this->load->view('templates/header', $data); $this->load->view('services/'.$page, $data); $this->load->view('templates/footer', $data); } else { $this->news_model->set_news(); $this->load->view('services/success'); } } }
Model
<?php class Services_model extends CI_Model { public function __construct() { $this->load->database(); } function insert_entry() { $data = array( 'title' => $title, 'sname' => $name, 'fname' => $name, 'email' => $name, 'state' => $name, 'tel' => $name, 'msg' => $name, 'date' => $date ); $this->db->insert('advisory', $data); } }
View
<?php echo validation_errors(); ?> <?php echo form_open('services/advisory'); ?> <table width="80%" border="0" cellspacing="2" cellpadding="0"> <tr> <td align="right"> Title:</td> <td><select name="title" id="title"> <option value="mr">Mr</option> <option value="mrs">Mrs</option> <option value="ms">Ms</option> </select></td> </tr> <tr> <td align="right">Surname:</td> <td><input name="sname" type="text" id="sname" /></td> </tr> <tr> <td align="right">First Name:</td> <td><input name="fname" type="text" id="fname" /></td> </tr> <tr> <td align="right">Email:</td> <td><input name="email" type="text" id="email" /></td> </tr> <tr> <td align="right">State:</td> <td><input name="state" type="text" id="state" /></td> </tr> <tr> <td align="right">Telephone</td> <td><input name="tel" type="text" id="tel" /></td> </tr> <tr> <td align="right">Topic:</td> <td><select name="topic" id="topic"> <option value="0" selected="selected">Select Topic</option> <option value="1">PAYE</option> <option value="2">Capital Restructuring</option> </select></td> </tr> <tr> <td rowspan="2"> </td> <td><textarea name="msg" id="msg"></textarea></td> </tr> <tr> <td><input name="date" type="hidden" id="date" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form>
thanks
-
A controller can use many different models, but a model generally represent a single table when modelling stuff from a database.
are you saying i can have one controller but different models for each table?
tally into MySQL
in MySQL Help
Posted
hi all.
don't know if this is the right forum for this but pls bear with me. Is there a way to import tally data into MySQL? vise-versa
thanks