₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,153 members, 8,420,588 topics. Date: Friday, 05 June 2026 at 05:34 AM

Toggle theme

Kentc3's Posts

Nairaland ForumKentc3's ProfileKentc3's Posts

1 (of 1 pages)

ProgrammingHow To Change An Input Field Using Onchange Handler, And Submit by kentc3(op): 1:55pm On Dec 01, 2016
Please, i need your help. I am new to jquery and am in need of it to achieve a task. Please help me out. Beow is a snippet of my code and what i intend to achieve below, after the snippet...





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
$(document).ready(function (e) {
$("#form"wink.on('submit',(function(e) {
e.preventDefault();
//$("#result"wink.empty();
//$('#loading').show();
$.ajax({
url: "show.php", // Url to which the request is send
type: "POST", // Type of request to be send, called as method
data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) // A function to be called if request succeeds
{
//$('#loading').hide();
$("#result"wink.html(data);
}
});
}));
});



</script>





</head>

<body>

<div id="table">
<div id="result" style="background-color:red; height:20px; width:200px;"></div>
<form method="post" action="" id="form" enctype="multipart/form-data">
<table style="width: 100%">
<tr>
<td style="height: 25px; width: 88px">Amount</td>
<td style="height: 25px">

<input name="name" style="width: 161px; height: 29px" type="text" id="name" placeholder="Input amount" onchange/><br/>
</td>
</tr>
<tr>
<td style="height: 25px; width: 88px">&nbsp;calculate</td>
<td style="height: 25px">

<input name="Text1" type="text" id="calculate"/>&nbsp;</td>
</tr>
<tr>
<td style="height: 25px; width: 88px">&nbsp;</td>
<td style="height: 25px">

<input name="pwd" type="text" placeholder="Name"/>&nbsp;</td>
</tr>
<tr>
<td style="width: 88px; height: 30px;">&nbsp;</td>
<td style="height: 30px">

<input style="width: 99px; height: 41px" type="submit" value="Register" name="submit" /></td>
</tr>
</table>
</form>
</div>

</body>

</html>




What i intend to achieve is: Once the value in amount field changes, it goes to a .php page, calculate and display the result as a value in another input field called calculate. When the submit button is pressed, it moves the form to show.php, store in database, and output the result...


I have tried different methods, but am finding it difficult displaying the values in an input field. Please i need your help..

Thanks
PoliticsRe: Why We Bought N3.6bn Exotic Cars During Recession –reps by kentc3: 9:52am On Nov 18, 2016
WebmastersHow To Buy And Sell Bitcoin From My Website by kentc3(op): 4:27am On Oct 12, 2016
Good Morning all, please, i am trying to create a website that a user can buy and sell bitcoins from me. The issue is that am confuse on how to go about the creation. I was wondering if there is any third party site i can be referred to, which i can just incorporate into my site or better still if i can create it myself using blockchain API.. Please, i will love to know what your opinion are and how to achieve positive result.. Thanks
Christianity EtcRe: Fr. Mbaka Creates 4500 Jobs In Enugu State! by kentc3: 5:08pm On Nov 18, 2015
if i be your father, i for pour the sperm way produce you for toilet...... anu ohia
moderation2020:
I am no sentimentalist, the truth must be told, the love of mobey is the beginning of wisdom. I think the boundry has been crossed between heavenly race and worldly race
Jokes EtcRe: Which Rat Will You Kill First, Why? by kentc3: 7:27pm On Jun 20, 2015
Guy, See as i dy laugh dy cry because of you!! Lol.....Very Funny Comment Indeed
Tapout:
but why will rats be eating all my important documents at the same time? undecided
WebmastersRe: Post All Your Web Development Issues Here (php, Sql, Html, Javascript, Css) by kentc3: 8:12am On May 02, 2015
Owk....how do i contact you please?
JackOfAllTrades:
the documentation are on their website, you can contact me I will help you set it up
WebmastersRe: Post All Your Web Development Issues Here (php, Sql, Html, Javascript, Css) by kentc3: 7:17pm On Apr 30, 2015
Please, i will like to play videos on my site by generating it from my database.. the problem is that, i do not want to use html5 video tag to do that.. i want something sophisticated like video.js or jw player... but i do not know how to embed it on my webpage... can u help or show me where to get a video tutorial on that.. thanks
WebmastersRe: Post your PHP Problems Here by kentc3: 8:01pm On Apr 25, 2015
Where can i find a tutorial on how to use the jwplayer or video.js
Adesege:
Try to take a look at jplayer or video.js. They are good plugin to achieve ur aim.
PoliticsRe: Bomb Explosion Rocks Enugu Polling Unit by kentc3: 10:17am On Mar 28, 2015
WebmastersRe: Post your PHP Problems Here by kentc3: 10:51pm On Mar 09, 2015
Adesege:
Try to take a look at jplayer or video.js. They are good plugin to achieve ur aim.
Owk... thank you very much, i will try it out...
WebmastersRe: Post your PHP Problems Here by kentc3: 3:55pm On Mar 09, 2015
Good Day Guys, Please i will want to play videos on my website, but do not want to make use of the HTML5 Video tag to do that.... i tried using jw player but the process of setting up the ftp and embedding in my web page and so on, seems to be cumbersome.... please i will love someone to assist me with other ways of achieving this .... thanks. anticipating your replies.
WebmastersRe: Post your PHP Problems Here by kentc3: 5:48pm On Feb 27, 2015
xyluz:
Try uploading the file without changing the name.

Try these debugging tips:

Did you check inside the images folder?
Is the image there?
If the image is there what name does it have?
Manually put an image inside the image folder (copy and paste), then try using your code to display the image...

Does it display the manually uploaded image?

Hope this was helpful?


Updated: check the image
Thank you very much, it is now working...... i remove the dirname, and moved the file to the directory straight, without changing the name of the file... SEE MY CHANGES BELOW

I replaced this
$newname=dirname().'/images1/'.$filename;
if(!file_exists($newname))
{
if((move_uploaded_file($_FILES['photo']['tmp_name'],$newname)))
{


with this below
$newname='images1/'.$filename;
if(!file_exists($newname))
{
if((move_uploaded_file($_FILES['photo']['tmp_name'],$newname)))
{


And it is now working..... Thanks, i really appreciate
WebmastersRe: Post your PHP Problems Here by kentc3: 8:26pm On Feb 26, 2015
xyluz:
Try This:

<?php
mysql_connect( "localhost","Gospel","gospel" ) or die( "Could not connect" );
mysql_select_db("picture"wink or die("could not select db"wink;

$select=mysql_query( "SELECT * from `pix` WHERE sn= 23" ) or die( "could not find" );

if($select)
{
$me=mysql_fetch_array($select);

echo "<img src='$me[image]' height='200' width='120'>";

}
?>


If it doesn't work, you can debug by doing var_dump($me), if the image path is being displayed then the problem is your image tag.

++++++++++++++++++++++++++++++++++++++++++++++

FURTHER OBSERVATIONS



Try this:

$ext = $_FILES["photo"]["type"].

That way you can say :

if(($ext == "image/jpg"....)){
...
}

This checks if your file is an image and that it has the right extension.


Try not to use $_POST directly, or any other global variable directly, its better you use some kind of filter like

filter_input(INPUT_POST, $fieldname) - read more on that here: http://php.net/manual/en/function.filter-input.php

In my opinion, your database connection should be the first thing you do, if the database is not connected, there's no use doing anything else.


I hope this was helpful.
The issue remained the same.... i used the var_dump($me) as u said, and the image path was displayed.... the question now is, how do i rectify it coz i have tried all possible ways i know to no avail.... please help out.. i am getting error such as this

array (size=4)
'sn' => string '11' (length=2)
'fname' => string 'll' (length=2)
'lname' => string 'll' (length=2)
'image' => string 'C:wampwwwimage.sample/images1/20141216_183233.jpg' (length=49)
WebmastersRe: Post your PHP Problems Here by kentc3: 2:56pm On Feb 26, 2015
This code Uploads a picture into a database, but when i try to retrieve it and display it, the result is blank... i need you guys assistant on how to overcome this coz i ve been stuck here for weeks.. i will really appreciate it... Below is the Upload Script

if(isset($_POST['submit']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$pic=$_FILES['photo']['name'];

if((!empty($_FILES['photo'])) && ($_FILES['photo']['error']==0))
{
$filename=basename($_FILES['photo']['name']);
$ext= substr($filename, strrpos($filename,'.')+1);
if(($ext == "jpg" || $ext == "gif" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG" || $ext == "PNG" || $ext == "png" || $ext == "GIF"wink &&($_FILES['photo']['size']<100000000))
{

$newname=dirname(__FILE__).'/images1/'.$filename;
if(!file_exists($newname))
{
if((move_uploaded_file($_FILES['photo']['tmp_name'],$newname)))
{

mysql_connect("Localhost","Gospel","gospel"wink or die("Could not connect"wink;
mysql_select_db("picture"wink or die("could not select db"wink;
$insert=mysql_query("INSERT INTO `pix`(`sn`, `fname`, `lname`, `image`) VALUES (NULL,'".$name."','".$email."','".$newname."')"wink or die("database not found"wink;
echo "<img src='$pic' alt='' height='300' width='500'>"."<br>";
echo "<img src='$newname' alt='' height='300' width='500'>"."<br>";
echo "its done! the file has been saved as:".$newname;
}
else
{
echo "Error! problem occured";
}}
else
{
echo "error file:".$_FILES['photo']['name']."already exist";
}}
else
{
echo "File format not supported";
}}
else
{
echo "thank you, no file uploadedd";
}


}


BELOW IS THE RETRIEVE AND DISPLAY SCRIPT

<?php
mysql_connect("Localhost","Gospel","gospel"wink or die("Could not connect"wink;
mysql_select_db("picture"wink or die("could not select db"wink;

$select=mysql_query("SELECT * from `pix` WHERE sn= 23 "wink or die("could not find"wink;
if(mysql_num_rows($select)==true)
{
$me=mysql_fetch_array($select);
?>
<img src="<?php echo $me['image']; ?>" alt="" height="200" width="120">
<?php
}
?>


Please i need a solution... Thanks

1 (of 1 pages)