|
I am making php page.
In my php page, exit() function calls in serveral places and i declared sqlite3::open() function in first line of php.
Closing db before each exit function makes code complex.
So i don't close sqlite db at the end is ok?
Please help me
|
|
|
|
|
Member 14490964 wrote: In my php page, exit() function calls in serveral places You need to redesign your page.
|
|
|
|
|
|
Detail of what? We have no idea what your code does or why. It is up tp you to review it and figure out why you have all these exit calls, and why you are leaving open databases if the code terminates.
|
|
|
|
|
please sir, i am new in web application development. and i am in desprate need of PHP and MSQLI codes that can link my php page to a form in excel sheet and at after the form is filled, once i click the send button it sends the information to database.
|
|
|
|
|
|
Database data export is a familiar operation for many of us. phpMyAdmin is the go to choice for a database client in PHP. It provides database administration tools and also allows exporting the data. The exported data can be in various formats like SQL, CSV as selected.
Please let me know if below code is useful. I used it for adding same functionality on my website here.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Here is another good reference https://phppot.com/php/database-data-export-to-excel-file-using-php/
|
|
|
|
|
I am using xampp apache server.
The server domain is registered in cloudflare.
All works well.
But cloudflare ip is saved in access.log
So I have done googling about restore real ip of cloudflare.
But I only found the way in linux apache server.
How can i resotore real ip in access.log of xampp server registered in cloudflare.
|
|
|
|
|
Message Removed
modified 14-Jul-20 15:02pm.
|
|
|
|
|
Hi all,
I did a small database and web page to help me control the time I work for my customers...
Today I've thought on adding graph capabilities to perform reports.
Given this thing is coded using PHP, some jquery and used a MySQL database, what would you recommend me?
I'm searching for a good looking free graph library.
Thank you all!
|
|
|
|
|
I want to redirect from http to https using express framework.
It is my code and it works properly, but i am not sure is it right way to redirect from
http to https. Anybody knows is my solution right?
var fs = require('fs');
var https = require('https');
var config = require( ".\\config\\config.json");
var folder = __dirname + '\\SSLCERT\\';
var fkey = folder + 'privatekey.key';
var fcert = folder + 'certificate.crt';
var privateKey = fs.readFileSync(fkey, 'utf8');
var certificate = fs.readFileSync(fcert, 'utf8');
var credentials = {key: privateKey, cert: certificate};
var express = require('express');
var app = express();
var https_mode = false;
app.get('/', function (req, res) {
if (https_mode == false) {
res.redirect('https://localhost:' + config.port_https);
https_mode = true;
}
else{
res.send('Hello World!!!');
https_mode = false;
}
})
app.listen(config.port_http,()=> {
console.log('listening on ' + config.port_http);
});
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(config.port_https, () => {
console.log('listening on ' + config.port_https) });
|
|
|
|
|
Hi All,
I have a thousand odd points of data, (city,state) describing the countries top high schools. I was wondering what an effective way to graph this would be.
I have the data in a PDF, so I'm currently working on scraping that into .CSV form.
Does the city/state location need to by long/latitude? I see a number of tools out there, just wondering what is the easiest to get started on a project like this.
My background is Linux Admin, some HTML and of course bash scripting. I would like to learn how to do this using golang if possible.
Thansk!
|
|
|
|
|
I think other people can give better answers but if all goes to hell, you can try with Python. Python has extensive libraries to help you in this regard.
|
|
|
|
|
if an airline booking tickets website is hard to do ?
and what is best website idea i can do it for a project?
|
|
|
|
|
moustafa arabi wrote: airline booking tickets website is hard to do ? Extremely unless you are only doing this as a learning exercise that will never go into production. It can be fascinating winkling out all the nuances required for passenger booking.
I found the best training method (besides working through a book or two) was to pick a hobby you or a friend knows and build a solution based on that. Then you have the domain knowledge available to you.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I don’t know if this question belongs to this forum.
I'm developing a website with vb.net web application using visual studio 2015 where a client is able to download a pdf file and I have considered 2 approaches as follows.
Dim sqlcom As New SqlCommand("select bookcontent,bookname from books where bookn=" & Page.RouteData.Values("bookn").ToString & "", conn)
Dim da As New SqlDataAdapter(sqlcom)
Dim ds As New DataTable
da.Fill(ds)
Dim filename As String = ds.Rows(0)("bookcontent").ToString
Dim fff As String = ds.Rows(0)("bookname").ToString
Dim fileInfo As FileInfo = New FileInfo(filename)
If fileInfo.Exists Then
Response.Clear()
Response.Buffer = True
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "Application/pdf"
Response.ContentType = "application/ms-word"
Response.AddHeader("Content-Disposition", "inline; filename=""" & ds.Rows(0)("bookname").ToString & ".pdf" & """")
Response.AddHeader("Content-Length", fileInfo.Length.ToString())
Response.TransmitFile(filename)
Response.Flush()
HttpContext.Current.ApplicationInstance.CompleteRequest()
I'm having trouble with the first approach above because when downloaded start the website
Hang on until pdf file fully downloaded to client PC ,this is bad since website will be access
By thousand of users every day,so I want to make the download process asynchronous.
I use the .NET Framework WebClient class in the second approach:
Dim Client As New WebClient
Dim weburl As String= ....here is some procedure to get url
Client.DownloadFileAsync(New Uri(weburl), @"c:\myfile.pdf")
But the problem here is that a path must be set and I want clients to get the file in the default download folder according to the Internet browser they use and the download process not appear through browser user can't see downloading file progress .
I will very much appreciate any comment that points me in the direction to solve this issue.
Thanks a lot.
|
|
|
|
|
The second approach isn't going to work, your code is running on the server so when you download to c:\myfile.pdf it will download from the url to that path on the server and not the client's machine. It might appear to work when running the site locally, but that is only because the client and server are the same machine, when you host it remotely it'll stop working.
You'll need to stick with the first method but I wouldn't worry about it, just let IIS deal with the threading for you.
|
|
|
|
|
Amer Amer wrote:
Dim sqlcom As New SqlCommand("select bookcontent,bookname from books where bookn=" & Page.RouteData.Values("bookn").ToString & "", conn) Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
Dim ds As New DataTable
Using sqlcom As New SqlCommand("select bookcontent,bookname from books where bookn = @bookn", conn)
sqlcom.Parameters.AddWithValue("@bookn", Page.RouteData.Values("bookn"))
Dim da As New SqlDataAdapter(sqlcom)
da.Fill(ds)
End Using
If ds.Rows.Count <> 0 Then
Dim filename As String = ds.Rows(0).Field(Of String)("bookcontent")
Dim fff As String = ds.Rows(0).Field(Of String)("bookname")
Dim fileInfo As FileInfo = New FileInfo(filename)
If fileInfo.Exists Then
Response.Clear()
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "inline; filename=""" & fff & ".pdf" & """")
Response.AddHeader("Content-Length", fileInfo.Length.ToString())
Response.TransmitFile(filename)
Response.Flush()
Context.ApplicationInstance.CompleteRequest()
Return
End If
End If Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
As already mentioned, this is the only way to send the file to the user. IIS is pretty good at handling file transfers; requests from other users shouldn't be blocked whilst the file is downloading.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank for the support Its work, your code very useful and your advice is valuable.
modified 10-Jun-20 17:14pm.
|
|
|
|
|
I'm trying to decide here.
If I create an account on my Web App, using my email address me@mywebapp.com, and then later I'm offered the opportunity to login to my Web App using Google SignIn; because I just wrote the code to add this feature, and elected to use it.
A:
Should I use googleUser's email address (me@mywebapp.com) as the account name, because I want to create an account to represent the user. But id the email is in use already, just update the login, and use the googleUser token to authenticate again, to AuthGuard.
Pro's:
I can login using either method to the same account.
Con's:
I can't really think of any, which is why I'm asking. Am I over looking something, perhaps someone's experience can say ... "No don't do that because ...".
B:
Use googleUsers first and last name, and sort of create a new account name from it that is unique.
Pro's:
I can't think of any
Con's:
EBay did this to me, and I ended up with 2 EBay accounts; didn't realize it for months, and really wish I just had the one.
Sounds like a dumb question, but wanted to ask before going into production mode.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
In the company intranet where I work there is a web-based documentation system that you can access through a regular web browser (Chrome, Firefox, Edge, etc). I need to write an application (in C#) that interfaces to this documentation system and I'm currently working on making sure that I can programmatically supply the user name and password correctly. When accessing the documentation system through a web browser, I always have to supply the user name and password once after re-boot and then I never have to type it again until next re-boot. I've come to the conclusion that the user name and password are being stored somewhere in the computer, but they are not stored in the browsers themselves and if I go to Control Panel -> User Accounts -> Credential Manager I see mostly Microsoft related passwords (Microsoft Outlook, Microsoft Office, XboxLive, SSO_POP_Device, virtualapp/didlogical, tfs, etc). Does anybody know where the user name and password could be stored and how I can remove them (without rebooting my computer) in order to be able to verify that my code supplies the user name and password correctly? I already asked the IT-manager (who's also in charge of the documentation system) and he didn't know.
|
|
|
|
|
Does it display a form within the site to enter the credentials, or does it pop up the "Windows authentication" dialog box?
If it's a form within the site, then the site is probably setting an authentication cookie. This won't contain the credentials (unless the site was written by someone who didn't know what they were doing!); instead, it will contain a signed and encrypted token which the server can use to identify the user. If you clear the cookies for the site, then you should be prompted to log in again.
If it's popping up the "Windows authentication" dialog box, then the browser will cache the credentials securely until it is closed. When you close and reopen the browser, you should be prompted to log in again.
For Internet Explorer, you can clear the Windows authentication cache without closing the browser by executing the (non-standard; deprecated) command:
document.execCommand("ClearAuthenticationCache", false);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, it's Windows Authentication. Chrome and Interner Explorer are still running in the Ctrl+Alt+Delete task manager, even though all windows are closed so I guess that's why they remember the credentials. Thank you for solving this.
modified 19-May-20 15:25pm.
|
|
|
|
|
For Chrome, there's a setting you might need to change:
Settings ⇒ Advanced ⇒ System ⇒ Continue running background apps when Google Chrome is closed
If it's on, Chrome will continue running even if you close all windows.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm working on a filter for a Custom Post Type . I need it to filter the list depending on the user's role. The way this should work is the following...
- Users in roles "formusers1" and "formusers2" can post. Users can only see their own posts.
- Users in role "formchecker1" can see all posts assigned role "formusers1' and can approve each post.
- Users in role "formchecker2" can see all posts assigned role "formusers2' and can approve each post.
- Users in roles "formsupervisor" and "administrator" can see everyone's posts.
So far I can filter by roles "formusers1" and "formusers2" using:
$query->set('author', $current_user->ID); However, when try to filter the list for role "formchecker1" I see posts from all roles. What am I doing wrong? Here's the rest of the code. Thanks for checking out!
add_action('pre_get_posts', 'filter_posts_list');<br />
<br />
function filter_posts_list($query) {<br />
global $pagenow, $typenow;<br />
<br />
global $current_user;<br />
get_currentuserinfo();<br />
<br />
if (current_user_can('formchecker1') && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt' ) {<br />
$query->set('author', 'formusers1');<br />
}<br />
<br />
if (current_user_can('formchecker2') && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt' ) {<br />
$query->set('author', 'formusers2');<br />
}<br />
<br />
if ((current_user_can('formusers1') || current_user_can('formusers2')) && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt') {<br />
$query->set('author', $current_user->ID);<br />
}<br />
}
|
|
|
|
|