Posts tagged "PHP code"

I have created a php coding to insert data in to the my sql database table. But the records are not inserti?

I have created a php coding to insert data in to the my sql database table. But the records are not inserting.
I have created a form using html and wrote the coding in php to insert records in to the database table in mysql. But the data that I insert using the form are not inserting in to the table. But there is no error message even. Please help?
Here is my coding.
<html>
<head>
</head>
<body>
<table>
<form method="post" action="exe_2.php">

<tr>
<td>User Name</td>
<td><input type="text" name="name"></td>
</tr>

<tr>
<td>Password</td>
<td><input type="password" name="paword"></td>
</tr>

<tr>
<td>Email</td>
<td><input type="text" name="email"></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="submit" value="register"></td>
</tr>
</table>
</form>

</body>

</html>

<?php
error_reporting(0);
$con = mysql_connect("localhost","root","root");
mysql_select_db("bit",$con);
$insert="INSERT INTO student
(StdNo,User Name,Password,Email) VALUES
(‘null’,'$_POST[name]‘,’$_POST[paword]‘,’$_POST[email]‘)";

//if (isset($_POST['submit']))
//{
mysql_query($insert,$con);
echo "your record added";
//}
$view="SELECT * FROM student";
$result=mysql_query($result,$con);
echo "<table border=’1′>
<tr>
<th>StdNo</th>
<th>User Name</th>
<th>Password</th>
<th>Email</th></tr>"
;

while ($display=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $display['StdNo'] . "</td>";
echo "<td>" . $display['User Name'] . "</td>";
echo "<td>" . $display['Password'] . "</td>";
echo "<td>" . $display['Email'] . "</td>";
echo "</tr>";
}

echo "</table>";

mysql_close($con);
?>

Below you will find code that should help you solve problems with your original. Because I was unsure of your table definition, I based the code on the following schema:

CREATE TABLE student(
StdNo BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Email VARCHAR(50),
User_Name VARCHAR(50),
Password VARCHAR(50),
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);

In the above schema StdNo an auto incrementing field. I replaced the space with an underscore in the field name "User Name" because MySQL must operate in a special mode in order to understand field names with spaces. I also added a timestamp field so that you would know when the record was created or last upaded.

I made the registration form a function that you can call at any point in order to display the form.

If you have the correct schema in your database, you can load the code below into a single php page and it should work.

Note that I do echo the function mysql_error() to the user when an error is ecountered with the SQL call. This is not recommended for production as hackers might find important info from the displayed error.

********** THE CODE **********

<?php
function showRegForm() {

// *** This funtion displays a registration form.

$pageName = $_SERVER['PHP_SELF'];

echo("<html>
<head>
</head>
<body>

<table>

<form method=\"post\" action=\"$pageName\">

<tr>
<td>User Name</td>
<td><input type=\"text\" name=\"name\"></td>
</tr>

<tr>
<td>Password</td>
<td><input type=\"password\" name=\"paword\"></td>
</tr>

<tr>
<td>Email</td>
<td><input type=\"text\" name=\"email\"></td>
</tr>

<tr>
<td></td>
<td><input type=\"submit\" name=\"cmdSubmit\" value=\"register\"></td>
</tr>
</table>
</form>

</body>

</html>");

return true;

}
if (isset($_POST["cmdSubmit"])) {

// *** Submit button was pressed.
// *** Process registration.

// *** Connect to database or quit.
$con = mysql_connect("localhost","root","root") Or exit("<p><b>ERROR:</b> Could not connect to datbase.</p>\n");

// *** Select database.
mysql_select_db("bit",$con) Or exit("<p><b>ERROR:</b> Could not select target datbase (bit).</p>\n");

// *** Build registration query.

$userName = mysql_real_escape_string ($_POST["name"], $con);
$password = mysql_real_escape_string ($_POST["paword"], $con);
$email = mysql_real_escape_string ($_POST["email"], $con);

$insert = "INSERT INTO student (User_Name, Password, Email) VALUES (‘$userName’,'$password’, ‘$email’)";

// *** Run the query.
$result = mysql_query($insert, $con);

if (!$result) {

// *** Error creating record. Inform user and halt.
exit("<p><b>ERROR: Could not create record.</b> " . mysql_error() . "</p>");

} else {

echo("<p>Your record added.");

// *** Now output list of records.

$view = "SELECT * FROM student";
$result = mysql_query($view, $con);

if (!$result) {

// *** Error getting records. Inform user and halt.
echo("<p><b>ERROR: Could not retrieve list of records.</b> " . mysql_error() . "</p>");

} else {

// *** Show record list.
// *** Note: A bad idea to show this to users.

echo("<table border=’1′> \n
<tr> \n
<th>Created</th> \n
<th>StdNo</th> \n
<th>User Name</th> \n
<th>Password</th> \n
<th>Email</th></tr> \n");

while ($display = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td> " . $display['last_update'] . "</td>";
echo "<td> " . $display['StdNo'] . "</td>";
echo "<td> " . $display['User_Name'] . "</td>";
echo "<td> " . $display['Password'] . "</td>";
echo "<td> " . $display['Email'] . "</td>";
echo "</tr>";
}

echo "</table>";

}

// *** Show registration form in case they want to register again.
echo("<h5>Register Another?</h5>");
$showForm = showRegForm();
}

// *** Close the db connection.
mysql_close($con);

} else {

// *** Submit button was NOT pressed, so show registration form.

$showForm = showRegForm();

}

?>


How to Find the HTML Coding of Any Website

In this video I’ll show you a quick little technique you can use to get the HTML coding out of any website. You can now use codes from other websites for your very own!

I hope you enjoy this video tutorial. Please comment, rate, and subscribe. If you have any questions, please post it in the comments. Thanks for watching!

Duration : 0:1:24

Read more…


How to enable localhost for PHP coding?

I’m doing php programming for my client’s website (noob) and i have all sort of php codes in my php. When i tried to preview the php page on my computer, nothing shows up (e.g. the include file for menu). However, when I upload it to my client’s server, the include file is properly displayed.

I’ve search for answers as to what I was doing wrong (at first i thought my php codes were wrong) and later found out that i most probably have not enabled my localhost.

I’m doing my coding on dreamweaver so can anyone help me as to how i can enable localhost so i can easily preview my php pages on my computer and not having to upload the files to the server just to preview them?

Since you did not mention your computer’s operating system…

Installing IIS 6.0

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/750d3137-462c-491d-b6c7-5f370d7f26cd.mspx?mfr=true

Installing IIS on Windows XP Professional… http://www.webwizguide.com/kb/asp_tutorials/installing_iis_winXP_pro.asp

Installing IIS 7.0 on Windows Vista

http://learn.iis.net/page.aspx/28/installing-iis-70-on-windows-vista/


How do I use Hexadecimal or HTML coding on Notepad?

I need to know how to hex code. How do I do it on Notepad or other Windows 2000-Standard program? Please keep in mind I don’t have Word or any other Office program.

PSPad provides a convenient hex-editor.

However, hex-editing is typically used for altering binary files (non-text) files, and is therefore something very different from HTML coding (creating specially formatted text files).

When creating an HTML file, any text editor (such as Notepad) may be used.

Simply type the contents of the HTML file into Notepad (or a similar editor), and then save the file with a name ending in ".html". Subsequently opening the file in an Internet browser will cause the HTML code to be interpreted and rendered.

For example, try entering the following into Notepad and saving it as "test.html":


<html>
<body>
<p>This is a paragraph.</p>
<p style="color:red">This paragraph is in red.</p>
<ul>
<li>This is a list.</li>
<li>Each list item has a bullet point.</li>
</ul>
</body>
</html>
—-

Once the file is saved, double-clicking the file should cause it to load in your computer’s default browser (likely Internet Explorer or Firefox).

From there, it’s just a matter of learning the ins and outs of the various HTML tags.


Please can anybody help me in AJAX PHP coding?

Please can anybody help me in AJAX PHP coding. i am a webmaster and need help. please email me at pratikgreat2004@yahoo.com.

Go here: http://phpbuilder.com/

"In our last article, we introduced Ajax by developing a simple email validation application. In this article we are going to delve deeper into Ajax and explore how XSL can be used on both the client side (using Javascript) and on the server side (using PHP) to transform XML data into XHTML."


how do I display html/coding in forums posts?

I need to type in my html coding in a post at a forum but my coding is not showing up because it’s html…so what is the closing tags I need for my code to show up in my posts?

One thing you can do is replace each left angle brace with the < entity. This will cause the browser to display the actual angle brace rather than trying to interpret it as HTML code. For example:
<head>
<title></title>
</head>
<body>
<h1></h1>
</body>
</html>

should be written as

&lt;head>
&lt;title>&lt;/title>
&lt;/head>
&lt;body>
&lt;h1>&lt;/h1>
&lt;/body>
&lt;/html>

and will appear on the page as
<head>
<title></title>
</head>
<body>
<h1></h1>
</body>
</html>

This is tedious, but it will usually work.

A more satisfying solution (especially for yahoo answers, which messes up indentation) is to use pastebin.com.

Simply copy your code and paste it into pastebin.com, then insert the link.

Pastebin handles all the character conversion for you, and also adds line numbers and syntax highlighting. It’s really easy and it’s free.

The pastebin link for the same code looks like this:

http://aharris.pastebin.com/m3bb2335f


Which html editor is the best one for html and php coding?

Which html editor is the best one for html and php coding?

I am using dreamweaver for making my html and php pages, its giving good facility not only for the html but also for the php. So I think its the best. Its even having facility to support validations too.


HTML question, can anyone tell me the coding for opening a window within the page and opening a new page pls?

I would also like to know how to do html coding for bold and colours please. Thanks

1.If you are using HTML(XHTML) code…just with Hyperlink then… may be you are cding like ..e.g <a href="……">link</a>… If its so ..then put target="Blank" inside the <a> tag…. It will open in new window or leave it as it is….it will open in same window…!!

2. if you are using JavaScript to open new Window with JavaScript function calling then use like below…

<Script Language="JavaScript">
function open_wn() {
var load = window.open(give your WINDOW path here [e.g \public_htm\win\popup.htm]);
}
</Script>
And go to the line where you want to give the Window link and call the function e.g <a href="javascript:load()">Open Window</a>

Try my codes…


Can you figure out this PHP coding conundrum?

I’m doing an email/feedback form for a website, and got some PHP code generated for it at http://www.phpsuccesstools.com/do.php?page=feedback

When I correctly enter all the info, it spits out two PHP files and an html form to use. Easy cheesy. But when I go to test it, it doesn’t work, with the error of:

Warning: Call-time pass-by-reference has been deprecated in /home/content/k/g/e/kgebby/html/feedback.php on line 112

Line 112 in feedback.php says:

if (do_readfile_string(&$html,$filename))

More info:

• Based on other forum advice I’ve seen, I tried removing the & to no avail
• My website’s host is GoDaddy
• I tried it with another site hosted by HostMonster, and it worked!
• GoDaddy told me the host/server doesn’t factor into this problem, and aren’t helping me out at all
• I tried contacting PHPsuccesstools.com, but haven’t heard back
• When FTPing up, I tried leaving the three files generated in the root folder, or making a new folder for them
• Didn’t work whether I inserted the form into an existing page, or just FTPed the raw form html page and tested with that
• All files were FTPed in ASCII, per the PHP generator’s website
• I know nothing about PHP, and little about coding, hence my visit to a site that generates the form and code for me

Got any ideas, besides harassing GoDaddy more? I’m hoping for a coding solution that will just make it work.

Thank you!
Aha, thank you both for that insight. I don’t think the site offers a newer version, but I will look for a site that does.

Your script seems to use, not only deprecated functions, but also an over-complex structure. (3 files ???)
Go to http://www.web2coders.com and download the free "form to email" script.
The form contains a textarea (the comment), and sends the form contents to a given email address.
Very easy to use!
(Use Notepad++ or a text editor to edit and view the code…)


How can I convert a C++ code into HTML coding.?

I have a C++ code for a Turn-Based Battle system, but I can’t find out how to add it to a webpage without it listing just the code itself? Any Ideas on how I can convert the C++ coding into a HTML script?

I’m guessing your C++ code outputs graphics and what not. This kind of thing is going to be very hard to port to Javascript, though I guess you could try to remap the graphics calls to a Canvas object or something. If the code is text based, I guess you have some options – but it’s still a major programming job.

The simple answer is that there isn’t some "automatic" way. You’re going to need to know Javascript well enough to write the game in Javascript. You may be able to save some work by porting some of the old code – but you’ll be rewriting major chunks.

If you want to create this kind of a game in a browser, I suggest learning Flash, and starting pretty much from scratch.


« Previous PageNext Page »

Your Site Sample is Stephen Fry proof thanks to caching by WP Super Cache