<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP TUTORIAL - Coding Help - Codinghelp.in</title>
	<atom:link href="https://codinghelp.in/category/php-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://codinghelp.in</link>
	<description>PHP,HTML,CSS,JS,Wordpress,Blogger,Seo Tools,Domain,Hosting And Others Support</description>
	<lastBuildDate>Sun, 08 Sep 2024 13:50:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>Pixel Code Setup in Own Website with Google Analytics, Facebook Pixel</title>
		<link>https://codinghelp.in/pixel-code-setup-in-own-website-with-google-analytics-facebook-pixel/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pixel-code-setup-in-own-website-with-google-analytics-facebook-pixel</link>
					<comments>https://codinghelp.in/pixel-code-setup-in-own-website-with-google-analytics-facebook-pixel/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Sun, 08 Sep 2024 13:29:11 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=1052</guid>

					<description><![CDATA[<p>To get the Service Account JSON file required for accessing the Google Analytics API, follow these steps: Step 1: Create a Project in Google Cloud Console Go to the Google Cloud Console. Sign in with your Google account. Create a new project or select an existing project. Click on the Select a Project dropdown at [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/pixel-code-setup-in-own-website-with-google-analytics-facebook-pixel/">Pixel Code Setup in Own Website with Google Analytics, Facebook Pixel</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>To get the <strong>Service Account JSON file</strong> required for accessing the Google Analytics API, follow these steps:</p>
<h3>Step 1: Create a Project in Google Cloud Console</h3>
<ol>
<li>Go to the <a href="https://console.cloud.google.com/projectcreate" target="_new" rel="noopener">Google Cloud Console</a>.</li>
<li>Sign in with your Google account.</li>
<li>Create a new project or select an existing project.
<ul>
<li>Click on the <strong>Select a Project</strong> dropdown at the top of the page.</li>
<li>Click on <strong>New Project</strong> and follow the prompts to create one.<br />
<img fetchpriority="high" decoding="async" class="wp-image-1054 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-1.png" alt="" width="488" height="308" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-1.png 712w, https://codinghelp.in/wp-content/uploads/2024/09/image-1-300x189.png 300w" sizes="(max-width: 488px) 100vw, 488px" /></li>
</ul>
</li>
</ol>
<h3>Step 2: Enable the Google Analytics Reporting API</h3>
<ol>
<li>After selecting your project, go to the <a target="_new" rel="noopener">API &amp; Services Dashboard</a>.<br />
<img decoding="async" class="wp-image-1055 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-2.png" alt="" width="640" height="209" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-2.png 1054w, https://codinghelp.in/wp-content/uploads/2024/09/image-2-300x98.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-2-1024x335.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-2-768x251.png 768w" sizes="(max-width: 640px) 100vw, 640px" /></li>
<li>Click on <strong>Enable APIs and Services</strong> at the top.</li>
<li>Search for &#8220;Google Analytics Data API&#8221;.<br />
<img decoding="async" class="wp-image-1085 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-31.png" alt="" width="669" height="390" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-31.png 952w, https://codinghelp.in/wp-content/uploads/2024/09/image-31-300x175.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-31-768x448.png 768w" sizes="(max-width: 669px) 100vw, 669px" /></li>
<li>Click on <strong>Google Analytics Data API </strong>  and then click <strong>Enable</strong>.</li>
</ol>
<h3>Step 3: Create a Service Account</h3>
<ol>
<li>Go to the <a target="_new" rel="noopener">Credentials page</a>.</li>
<li>Click on <strong>Create Credentials</strong> and select <strong>Service Account</strong>.<br />
<img loading="lazy" decoding="async" class="wp-image-1057 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-4.png" alt="" width="640" height="263" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-4.png 1029w, https://codinghelp.in/wp-content/uploads/2024/09/image-4-300x123.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-4-1024x421.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-4-768x316.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>Fill in the details:
<ul>
<li><strong>Service Account Name:</strong> Give it a descriptive name (e.g., <code>Analytics Reporting Service Account</code>).</li>
<li><strong>Service Account ID:</strong> This will be auto-filled, but you can modify it if needed.<br />
<img loading="lazy" decoding="async" class="wp-image-1058 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-5.png" alt="" width="669" height="475" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-5.png 880w, https://codinghelp.in/wp-content/uploads/2024/09/image-5-300x213.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-5-768x545.png 768w" sizes="auto, (max-width: 669px) 100vw, 669px" /></li>
</ul>
</li>
<li>Click <strong>Create</strong> and proceed to the next step.</li>
</ol>
<h3>Step 4: Assign Permissions to the Service Account</h3>
<ol>
<li>After creating the service account, you will be prompted to assign roles.</li>
<li>Choose the <strong>Role</strong>: Select <strong>Viewer</strong> under <strong>Basic</strong> to give the service account read-only access.</li>
<li>Click <strong>Continue</strong> and then <strong>Done</strong>.</li>
</ol>
<h3>Step 5: Generate a JSON Key for the Service Account</h3>
<ol>
<li>Go to the <strong>Service Accounts</strong> page (under <strong>IAM &amp; Admin</strong>).</li>
<li>Click this Service Accounts Email.<br />
<img loading="lazy" decoding="async" class="wp-image-1059 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-6.png" alt="" width="408" height="261" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-6.png 916w, https://codinghelp.in/wp-content/uploads/2024/09/image-6-300x192.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-6-768x491.png 768w" sizes="auto, (max-width: 408px) 100vw, 408px" /></li>
<li>Find the service account you just created, and click on it.<br />
<img loading="lazy" decoding="async" class="wp-image-1060 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-7.png" alt="" width="582" height="393" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-7.png 852w, https://codinghelp.in/wp-content/uploads/2024/09/image-7-300x202.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-7-768x518.png 768w" sizes="auto, (max-width: 582px) 100vw, 582px" /></li>
<li>Under the <strong>Keys</strong> tab, click <strong>Add Key</strong> and choose <strong>JSON</strong>.<br />
<img loading="lazy" decoding="async" class="wp-image-1061 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-8.png" alt="" width="686" height="467" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-8.png 686w, https://codinghelp.in/wp-content/uploads/2024/09/image-8-300x204.png 300w" sizes="auto, (max-width: 686px) 100vw, 686px" /></li>
<li>A JSON file will be downloaded to your computer. This is your service account&#8217;s private key.<br />
<img loading="lazy" decoding="async" class="wp-image-1062 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-9.png" alt="" width="421" height="294" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-9.png 612w, https://codinghelp.in/wp-content/uploads/2024/09/image-9-300x209.png 300w" sizes="auto, (max-width: 421px) 100vw, 421px" /></li>
<li>Create button click after this message display: Private key saved to your computer<br />
<img loading="lazy" decoding="async" class="wp-image-1063 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-10.png" alt="" width="640" height="271" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-10.png 1075w, https://codinghelp.in/wp-content/uploads/2024/09/image-10-300x127.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-10-1024x433.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-10-768x325.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
</ol>
<h3>Step 6: Grant Access to Google Analytics</h3>
<p>before using Google Analytics to track data or access it via the API, your website must be added to Google Analytics. This involves:</p>
<h3>         How to Add Your Website to Google Analytics:</h3>
<ol>
<li><strong>Create a Google Analytics Account:</strong>
<ul>
<li>Go to <a href="https://analytics.google.com/" target="_new" rel="noopener">Google Analytics</a>.</li>
<li>Sign in with your Google account and create a new Analytics account.</li>
</ul>
</li>
<li><strong>Set Up a Property:</strong>
<ul>
<li>Once you are in the Analytics dashboard, click on <strong>Admin</strong> at the bottom left.<br />
<img loading="lazy" decoding="async" class="wp-image-1066 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-13.png" alt="" width="421" height="419" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-13.png 571w, https://codinghelp.in/wp-content/uploads/2024/09/image-13-300x298.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-13-150x150.png 150w" sizes="auto, (max-width: 421px) 100vw, 421px" /></li>
<li>Under the <strong>Account</strong> column, select <strong>Create Account</strong> if you are starting fresh, or use an existing account.<br />
<img loading="lazy" decoding="async" class="wp-image-1067 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-14.png" alt="" width="504" height="322" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-14.png 863w, https://codinghelp.in/wp-content/uploads/2024/09/image-14-300x192.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-14-768x490.png 768w" sizes="auto, (max-width: 504px) 100vw, 504px" /></li>
<li>Account name (Required), Google products and services, click on Next Button.<br />
<img loading="lazy" decoding="async" class="wp-image-1069 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-16.png" alt="" width="513" height="344" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-16.png 663w, https://codinghelp.in/wp-content/uploads/2024/09/image-16-300x201.png 300w" sizes="auto, (max-width: 513px) 100vw, 513px" /></li>
<li>Property name (Required), Reporting time zone,Currency this details fill after click on Next button.<br />
<img loading="lazy" decoding="async" class="wp-image-1070 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-17.png" alt="" width="532" height="438" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-17.png 583w, https://codinghelp.in/wp-content/uploads/2024/09/image-17-300x247.png 300w" sizes="auto, (max-width: 532px) 100vw, 532px" /></li>
<li>Industry category (Required), Business size (Required) this details fill after click on Next button.<br />
<img loading="lazy" decoding="async" class="wp-image-1071 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-18.png" alt="" width="359" height="366" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-18.png 553w, https://codinghelp.in/wp-content/uploads/2024/09/image-18-294x300.png 294w" sizes="auto, (max-width: 359px) 100vw, 359px" /></li>
<li>Choose your business objectives, all tick after click on <strong>Create</strong> button.<br />
<img loading="lazy" decoding="async" class="wp-image-1072 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-19.png" alt="" width="412" height="386" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-19.png 582w, https://codinghelp.in/wp-content/uploads/2024/09/image-19-300x281.png 300w" sizes="auto, (max-width: 412px) 100vw, 412px" /></li>
<li>Term and condition accept for click on <strong>I Accept</strong> button.<br />
<img loading="lazy" decoding="async" class="wp-image-1073 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-20.png" alt="" width="587" height="200" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-20.png 1127w, https://codinghelp.in/wp-content/uploads/2024/09/image-20-300x102.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-20-1024x348.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-20-768x261.png 768w" sizes="auto, (max-width: 587px) 100vw, 587px" /></li>
<li>Choose a platform section in click on <strong>web</strong> button.<img loading="lazy" decoding="async" class="wp-image-1074 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-21.png" alt="" width="640" height="240" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-21.png 1088w, https://codinghelp.in/wp-content/uploads/2024/09/image-21-300x113.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-21-1024x384.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-21-768x288.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>Website URL section :- Enter website url and website name then click on <strong>Create and Continue</strong> button.<br />
<img loading="lazy" decoding="async" class="wp-image-1076 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-23.png" alt="" width="714" height="310" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-23.png 1193w, https://codinghelp.in/wp-content/uploads/2024/09/image-23-300x130.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-23-1024x444.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-23-768x333.png 768w" sizes="auto, (max-width: 714px) 100vw, 714px" /></li>
<li>Set up a Google tag : copy this code and paste this code on your website.<br />
<img loading="lazy" decoding="async" class="wp-image-1077 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-24.png" alt="" width="662" height="212" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-24.png 802w, https://codinghelp.in/wp-content/uploads/2024/09/image-24-300x96.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-24-768x246.png 768w" sizes="auto, (max-width: 662px) 100vw, 662px" /></li>
<li>&lt;head&gt; this code below add this code then click on<strong> Save Changes</strong> button.</li>
<li>click on Test Installation button. then confirm button click, It checks whether the code has been properly added to the website or not.<br />
<img loading="lazy" decoding="async" class="wp-image-1078 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-25.png" alt="" width="605" height="421" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-25.png 791w, https://codinghelp.in/wp-content/uploads/2024/09/image-25-300x209.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-25-768x534.png 768w" sizes="auto, (max-width: 605px) 100vw, 605px" /></li>
<li>Next button click after this page show. Data Collection is pending.</li>
<li>Under the <strong>Property</strong> column, click <strong>Create Property</strong>.</li>
<li>Enter your website name, URL, industry category, and reporting time zone.</li>
</ul>
</li>
<li><strong>Set Up the Tracking Code (Pixel):</strong>
<ul>
<li>After setting up the property, Google Analytics will generate a tracking code (Pixel).</li>
<li>You need to copy this code and paste it into the <code>&lt;head&gt;</code> section of every page of your website that you want to track.</li>
<li>If you are using a CMS (like WordPress), you can use plugins to add the tracking code automatically.</li>
</ul>
</li>
<li><strong>Verify Tracking is Working:</strong>
<ul>
<li>After adding the tracking code, return to Google Analytics and verify that data is being received.</li>
<li>You can check this under the <strong>Real-Time</strong> section to see if your website visits are being tracked correctly.</li>
</ul>
</li>
</ol>
<ol>
<li>Open your <a href="https://analytics.google.com/analytics/web/" target="_new" rel="noopener">Google Analytics Account</a>.<br />
<img loading="lazy" decoding="async" class="wp-image-1080 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-26.png" alt="" width="640" height="379" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-26.png 1065w, https://codinghelp.in/wp-content/uploads/2024/09/image-26-300x177.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-26-1024x606.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-26-768x454.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>Go to <strong>Admin</strong> at the bottom left.</li>
<li>Under the <strong>Property</strong> column, click on <strong>Account Settings</strong> or <strong>Property Settings</strong> (depending on the scope of access you want to grant).<br />
<img loading="lazy" decoding="async" class="wp-image-1081 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-27.png" alt="" width="658" height="437" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-27.png 946w, https://codinghelp.in/wp-content/uploads/2024/09/image-27-300x199.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-27-768x510.png 768w" sizes="auto, (max-width: 658px) 100vw, 658px" /></li>
<li>Click on <strong>Account/Property Access Management</strong>.<br />
<img loading="lazy" decoding="async" class="wp-image-1082 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-28.png" alt="" width="640" height="137" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-28.png 1089w, https://codinghelp.in/wp-content/uploads/2024/09/image-28-300x64.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-28-1024x219.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-28-768x164.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>Click on the <strong>+ (Add Users)</strong> button and add the <strong>service account email</strong> (from the JSON file).<br />
<img loading="lazy" decoding="async" class="wp-image-1083 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-29.png" alt="" width="675" height="354" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-29.png 1022w, https://codinghelp.in/wp-content/uploads/2024/09/image-29-300x157.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-29-768x403.png 768w" sizes="auto, (max-width: 675px) 100vw, 675px" /></li>
<li>Enter Google Service Account Email id and tick on Administrator then click <strong>Add</strong> button.<br />
<img loading="lazy" decoding="async" class="wp-image-1084 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-30.png" alt="" width="640" height="115" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-30.png 1094w, https://codinghelp.in/wp-content/uploads/2024/09/image-30-300x54.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-30-1024x184.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-30-768x138.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>Assign the role <strong>Read &amp; Analyze</strong> to this service account.</li>
</ol>
<h3>How to add Custom definitions ?</h3>
<p>If you want to send or set a custom value and then get it through Google Analytics Api, it is mostly used to set and get Username or email address.</p>
<p>Here’s a step-by-step guide on how to add custom dimensions and metrics:</p>
<h3>1. <strong>Access Google Analytics Admin</strong></h3>
<ol>
<li><strong>Log in</strong> to your <a href="https://analytics.google.com/" target="_new" rel="noopener">Google Analytics</a> account.</li>
<li><strong>Navigate</strong> to the GA4 property where you want to add custom definitions.</li>
<li>Click on <strong>&#8220;Admin&#8221;</strong> at the bottom left of the page.<br />
<img loading="lazy" decoding="async" class="wp-image-1088 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-32.png" alt="" width="358" height="333" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-32.png 620w, https://codinghelp.in/wp-content/uploads/2024/09/image-32-300x279.png 300w" sizes="auto, (max-width: 358px) 100vw, 358px" /></li>
</ol>
<h3>2. <strong>Add Custom Dimensions</strong></h3>
<ol>
<li>Under the <strong>&#8220;Property Settings &gt;Data display &gt;Custom definitions&#8221;</strong> column, click on <strong>&#8220;Custom Definitions&#8221;</strong>.</li>
<li>Select <strong>&#8220;Custom Dimensions&#8221;</strong> from the options provided.<br />
<img loading="lazy" decoding="async" class="wp-image-1089 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-33.png" alt="" width="640" height="278" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-33.png 1294w, https://codinghelp.in/wp-content/uploads/2024/09/image-33-300x130.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-33-1024x444.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-33-768x333.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
</ol>
<h4>To create a new custom dimension:</h4>
<ol>
<li>Click the <strong>&#8220;Create Custom Dimension&#8221;</strong> button.<br />
<img loading="lazy" decoding="async" class="wp-image-1111 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-46.png" alt="" width="566" height="433" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-46.png 566w, https://codinghelp.in/wp-content/uploads/2024/09/image-46-300x230.png 300w" sizes="auto, (max-width: 566px) 100vw, 566px" /></li>
<li><strong>Enter a Dimension Name</strong>: This is how you will refer to this dimension name in your reports. For example, &#8220;<strong>Hashed User ID</strong>&#8220;.</li>
<li><strong>Scope</strong>: Choose the scope for the dimension. Common scopes are:
<ul>
<li><strong>User</strong>: The dimension will be applied to user-level data.</li>
</ul>
</li>
<li><strong>Description</strong>: Optionally, provide a description for the dimension.</li>
<li><strong>User property</strong>: Enter the name of the parameter that will be sent with your User property. For example, if you want to track Hashed User ID, enter <code>"hashed_user_id"</code> here.</li>
<li><strong>Save</strong> your custom dimension.<br />
<img loading="lazy" decoding="async" class="wp-image-1110 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-45.png" alt="" width="968" height="194" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-45.png 968w, https://codinghelp.in/wp-content/uploads/2024/09/image-45-300x60.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-45-768x154.png 768w" sizes="auto, (max-width: 968px) 100vw, 968px" /></li>
</ol>
<h3></h3>
<p>You can set custom definitions name like this.</p>
<h3>How to get Measurement Id or G-XXXXXXXX or GTag id ?</h3>
<p>To get Measurement ID or G-XXXXXXXXX or GTag id or config id, follow the steps given below &#8211;</p>
<ol>
<li>Open <strong>Google Analytics</strong> website then click on the <strong>Admin</strong> button on the left side bottom.<br />
<img loading="lazy" decoding="async" class="wp-image-1093 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-36.png" alt="" width="588" height="314" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-36.png 1040w, https://codinghelp.in/wp-content/uploads/2024/09/image-36-300x160.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-36-1024x546.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-36-768x410.png 768w" sizes="auto, (max-width: 588px) 100vw, 588px" /></li>
<li>Click on <strong>Property settings&gt;Data Collection and modification&gt;Data Streams</strong> button, then select website name in all section and data will show then click on it.<br />
<img loading="lazy" decoding="async" class="wp-image-1094 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-37.png" alt="" width="840" height="358" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-37.png 992w, https://codinghelp.in/wp-content/uploads/2024/09/image-37-300x128.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-37-768x327.png 768w" sizes="auto, (max-width: 840px) 100vw, 840px" />\</li>
<li>Measurement ID: This is how you can get this ID value.This is how you can get GA4 measurement ID</li>
</ol>
<h3>How to setup or set Google Analytics Custom Events Name ?</h3>
<p>If you want to create Google Analytics Event Name then follow the steps given below.</p>
<ol>
<li>Open Google Analytics Website then click on left side Admin button.<br />
<img loading="lazy" decoding="async" class="wp-image-1095 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-38.png" alt="" width="640" height="281" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-38.png 1305w, https://codinghelp.in/wp-content/uploads/2024/09/image-38-300x132.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-38-1024x450.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-38-768x338.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>After clicking on the Admin button, click on the Data Display button in the Property Settings section.</li>
<li>Click on Data Display &gt; Events button.</li>
<li>Click on the Create Event button.<br />
<img loading="lazy" decoding="async" class="wp-image-1096 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-39.png" alt="" width="647" height="256" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-39.png 733w, https://codinghelp.in/wp-content/uploads/2024/09/image-39-300x119.png 300w" sizes="auto, (max-width: 647px) 100vw, 647px" /></li>
<li>Click the Create button to setup a new event.<img loading="lazy" decoding="async" class="wp-image-1097 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-40.png" alt="" width="653" height="348" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-40.png 888w, https://codinghelp.in/wp-content/uploads/2024/09/image-40-300x160.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-40-768x409.png 768w" sizes="auto, (max-width: 653px) 100vw, 653px" /></li>
<li>Select or enter &#8220;login&#8221; option in Custom Event Name.</li>
<li>Enter or select &#8220;event_name&#8221; in parameter</li>
<li>Enter &#8220;user_signin&#8221; in the value.<img loading="lazy" decoding="async" class="wp-image-1098 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-41.png" alt="" width="781" height="231" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-41.png 781w, https://codinghelp.in/wp-content/uploads/2024/09/image-41-300x89.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-41-768x227.png 768w" sizes="auto, (max-width: 781px) 100vw, 781px" /></li>
<li>This is how you can successfully create a custom event name.</li>
</ol>
<p>&nbsp;</p>
<h3>How to get GA4 Property ID or Google Analytics  PROPERTY ID ?</h3>
<p>If you want to fetch data through Google Analytics API and for that you have to get property ID, then follow the steps given below.</p>
<ol>
<li>Open Google Analytics Website.</li>
<li>After opening the Google Analytics site, you have to click on the Admin button which is on the left side.<img loading="lazy" decoding="async" class="wp-image-1100 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/09/image-42.png" alt="" width="742" height="313" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-42.png 1329w, https://codinghelp.in/wp-content/uploads/2024/09/image-42-300x127.png 300w, https://codinghelp.in/wp-content/uploads/2024/09/image-42-1024x432.png 1024w, https://codinghelp.in/wp-content/uploads/2024/09/image-42-768x324.png 768w" sizes="auto, (max-width: 742px) 100vw, 742px" /></li>
<li>Click on the property button in the Property settings section.</li>
<li>Click on the Property Details button.</li>
<li>Then you will see the property ID on the right side which has to be copied, you can use it while calling Google Analytics API.</li>
</ol>
<p>From some you can get access to Google Analytics properties.</p>
<ul>
<li>Open your terminal and navigate to your project directory. Run the following command to require version <code>2.20</code> of <code>google/apiclient</code>:
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative">
<div class="flex items-center text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9">bash</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-main-surface-secondary px-2 font-sans text-xs text-token-text-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center py-1">Copy code</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">composer require google/apiclient:^2.20<br />
</code></div>
</div>
<p>The <code>^</code> operator allows Composer to install the latest compatible version within the specified major version. In this case, it will install <code>2.20.x</code> but not <code>2.21</code> or higher.</li>
<li></li>
</ul>
<p><span style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Error fetching real-time report: { &#8220;error&#8221;: { &#8220;code&#8221;: 400, &#8220;message&#8221;: &#8220;Selected dimensions and metrics cannot be queried together.&#8221;, &#8220;errors&#8221;: [ { &#8220;message&#8221;: &#8220;Selected dimensions and metrics cannot be queried together.&#8221;, &#8220;domain&#8221;: &#8220;global&#8221;, &#8220;reason&#8221;: &#8220;badRequest&#8221; } ], &#8220;status&#8221;: &#8220;INVALID_ARGUMENT&#8221; } } No data to display due to previous error.</span></p>
<p>The error <code>"Selected dimensions and metrics cannot be queried together"</code> in Google Analytics API occurs when you attempt to query a combination of dimensions and metrics that are incompatible with each other.</p>
<h3>Possible Causes:</h3>
<ol>
<li><strong>Mismatch between Dimensions and Metrics:</strong>
<ul>
<li>Not all metrics can be used with every dimension in Google Analytics. For example, certain metrics like <code>activeUsers</code> may not work with custom dimensions such as <code>hashed_user_id</code>.</li>
</ul>
</li>
<li><strong>Custom Dimensions/Properties:</strong>
<ul>
<li>Custom dimensions like <code>customUser:hashed_user_id</code> may not be compatible with some metrics or standard dimensions. Google Analytics may prevent combining certain metrics with user-defined custom dimensions.</li>
</ul>
</li>
<li><strong>Incorrect Scope:</strong>
<ul>
<li>Google Analytics defines metrics and dimensions under different scopes like <strong>User</strong>, <strong>Session</strong>, or <strong>Event</strong>. If you&#8217;re combining a <strong>User-scoped</strong> dimension like <code>hashed_user_id</code> with <strong>Event-scoped</strong> metrics, they won&#8217;t be compatible.</li>
</ul>
</li>
</ol>
<h3>How to Resolve:</h3>
<h4>1. <strong>Check Compatibility in GA4:</strong></h4>
<ul>
<li><strong>Google Analytics UI</strong>: Use the <strong>Explore</strong> section in GA4 to manually check which dimensions and metrics can be used together. Try adding your dimensions (<code>city</code>, <code>deviceCategory</code>, <code>hashed_user_id</code>) along with the metrics (<code>activeUsers</code>, <code>screenPageViews</code>) and see if the UI prevents any combinations.</li>
<li>If the UI flags the combination as incompatible, it&#8217;s a clear sign that they cannot be queried together via the API either.</li>
</ul>
<h4>2. <strong>Separate Queries:</strong></h4>
<ul>
<li>If the combination of <code>customUser:hashed_user_id</code> and the metrics like <code>activeUsers</code> is incompatible, you can run separate queries:
<ul>
<li>One for general metrics like <code>activeUsers</code> and <code>screenPageViews</code>.</li>
<li>Another one specifically targeting the <code>hashed_user_id</code> to avoid conflicts.</li>
</ul>
</li>
</ul>
<h4>3. <strong>Try Removing Incompatible Metrics/Dimensions:</strong></h4>
<ul>
<li>Start by querying with fewer dimensions/metrics and add them one by one to identify the conflicting pair. For example, remove <code>hashed_user_id</code> and see if it works:</li>
</ul>
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative">
<div class="flex items-center text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9">php</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-main-surface-secondary px-2 font-sans text-xs text-token-text-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center py-1">Copy code</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Google_Service_AnalyticsData_RunRealtimeReportRequest</span>();<br />
<span class="hljs-variable">$request</span>-&gt;<span class="hljs-title function_ invoke__">setMetrics</span>([<span class="hljs-variable">$activeUsers</span>, <span class="hljs-variable">$screenPageViews</span>]);<br />
<span class="hljs-variable">$request</span>-&gt;<span class="hljs-title function_ invoke__">setDimensions</span>([<span class="hljs-variable">$city</span>, <span class="hljs-variable">$deviceCategory</span>]); <span class="hljs-comment">// Start with standard dimensions</span></code></code><span class="hljs-comment">// If this works, you can try adding hashed_user_id separately</span></div>
</div>
<h4>4. <strong>Check API Documentation:</strong></h4>
<ul>
<li>Refer to the official <a target="_new" rel="noopener">Google Analytics API documentation</a> to see which dimensions and metrics are compatible. Custom dimensions may have additional constraints.</li>
</ul>
<h3>Adjusted Query with Focused Scope:</h3>
<p>Try querying <code>activeUsers</code> without any custom dimensions like <code>hashed_user_id</code> to test compatibility:</p>
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative">
<div class="flex items-center text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9">php</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-main-surface-secondary px-2 font-sans text-xs text-token-text-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center py-1">Copy code</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Google_Service_AnalyticsData_RunRealtimeReportRequest</span>();<br />
<span class="hljs-variable">$request</span>-&gt;<span class="hljs-title function_ invoke__">setMetrics</span>([<span class="hljs-variable">$activeUsers</span>, <span class="hljs-variable">$screenPageViews</span>]);<br />
<span class="hljs-variable">$request</span>-&gt;<span class="hljs-title function_ invoke__">setDimensions</span>([<span class="hljs-variable">$city</span>, <span class="hljs-variable">$deviceCategory</span>]); <span class="hljs-comment">// Only basic dimensions</span></code></code><span class="hljs-comment">// Remove custom dimensions for now</span></div>
</div>
<p>If this works, try a separate query for <code>hashed_user_id</code>:</p>
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative">
<div class="flex items-center text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9">php</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-main-surface-secondary px-2 font-sans text-xs text-token-text-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center py-1">Copy code</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><code class="!whitespace-pre hljs language-php"><span class="hljs-variable">$hashedUserIDDimension</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Google_Service_AnalyticsData_Dimension</span>();<br />
<span class="hljs-variable">$hashedUserIDDimension</span>-&gt;<span class="hljs-title function_ invoke__">setName</span>(<span class="hljs-string">'customUser:hashed_user_id'</span>);</code></code><span class="hljs-variable">$request</span>-&gt;<span class="hljs-title function_ invoke__">setDimensions</span>([<span class="hljs-variable">$hashedUserIDDimension</span>]); <span class="hljs-comment">// Only query hashed_user_id</span></div>
</div>
<p>This should help isolate and solve the issue by finding the right combination of dimensions and metrics.</p>
<h2><span style="font-size: 14pt;">Google Analytics Api Call in PHP ?</span></h2>
<p><img loading="lazy" decoding="async" class="wp-image-1104 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-43.png" alt="" width="576" height="275" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-43.png 576w, https://codinghelp.in/wp-content/uploads/2024/09/image-43-300x143.png 300w" sizes="auto, (max-width: 576px) 100vw, 576px" /></p>
<ul>
<li>Open your terminal and navigate to your project directory. Run the following command to require version <code>2.20</code> of <code>google/apiclient</code>:
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative">
<div class="flex items-center text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9">bash</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-main-surface-secondary px-2 font-sans text-xs text-token-text-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center py-1">Copy code</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><strong><code class="!whitespace-pre hljs language-bash">composer require google/apiclient:^2.20<br />
</code></strong></div>
</div>
<p><img loading="lazy" decoding="async" class="wp-image-1108 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/09/image-44.png" alt="" width="684" height="124" srcset="https://codinghelp.in/wp-content/uploads/2024/09/image-44.png 684w, https://codinghelp.in/wp-content/uploads/2024/09/image-44-300x54.png 300w" sizes="auto, (max-width: 684px) 100vw, 684px" /><br />
The <code>^</code> operator allows Composer to install the latest compatible version within the specified major version. In this case, it will install <code>2.20.x</code> but not <code>2.21</code> or higher.</li>
</ul>
<p><code></code></p>
<p><code>&lt;?php</code><br />
<code>error_reporting(E_ALL);</code><br />
<code>ini_set('display_errors', 1);</code><br />
<code>require 'google_analytics/vendor/autoload.php';</code></p>
<p>&nbsp;</p>
<p><code>use Google\Client;</code><br />
<code>use Google\Service\AnalyticsData;</code></p>
<p>&nbsp;</p>
<p><code>function initializeAnalytics() {</code><br />
<code>$KEY_FILE_LOCATION = 'metal-sky-434809-n7-xxxxxxxxxxx.json';</code></p>
<p>&nbsp;</p>
<p><code>$client = new Client();</code><br />
<code>$client-&gt;setAuthConfig($KEY_FILE_LOCATION);</code><br />
<code>$client-&gt;addScope(AnalyticsData::ANALYTICS_READONLY);</code></p>
<p>&nbsp;</p>
<p><code>return new AnalyticsData($client);</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>function getUserActivityReport($analyticsData) {</code><br />
<code>$PROPERTY_ID = '00000000'; // Replace with your GA4 Property ID</code></p>
<p>&nbsp;</p>
<p><code>// Get current date and time in Asia/Kolkata time zone</code><br />
<code>$dateTimeZone = new DateTimeZone('Asia/Kolkata');</code><br />
<code>$startDate = new DateTime('2024-09-06', $dateTimeZone); // Start date (can be modified as needed)</code><br />
<code>$endDate = new DateTime('now', $dateTimeZone); // End date: current time in Asia/Kolkata</code></p>
<p>&nbsp;</p>
<p><code>// Format the date in Y-m-d format</code><br />
<code>$startDateFormatted = $startDate-&gt;format('Y-m-d');</code><br />
<code>$endDateFormatted = $endDate-&gt;format('Y-m-d');</code></p>
<p>&nbsp;</p>
<p><code>// Date range</code><br />
<code>$dateRange = new Google_Service_AnalyticsData_DateRange();</code><br />
<code>$dateRange-&gt;setStartDate($startDateFormatted);</code><br />
<code>$dateRange-&gt;setEndDate($endDateFormatted);</code></p>
<p>&nbsp;</p>
<p><code>// Metrics</code><br />
<code>$activeUsers = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$activeUsers-&gt;setName('activeUsers');</code></p>
<p>&nbsp;</p>
<p><code>$averageSessionDuration = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$averageSessionDuration-&gt;setName('averageSessionDuration');</code></p>
<p>&nbsp;</p>
<p><code>$sessions = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$sessions-&gt;setName('sessions');</code></p>
<p>&nbsp;</p>
<p><code>$screenPageViewsPerUser = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$screenPageViewsPerUser-&gt;setName('screenPageViewsPerUser');</code></p>
<p>&nbsp;</p>
<p><code>$eventCount = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$eventCount-&gt;setName('eventCount');</code></p>
<p>&nbsp;</p>
<p><code>$bounceRate = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$bounceRate-&gt;setName('bounceRate');</code></p>
<p>&nbsp;</p>
<p><code>$newUsers = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$newUsers-&gt;setName('newUsers');</code></p>
<p>&nbsp;</p>
<p><code>$scrolledUsers = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$scrolledUsers-&gt;setName('scrolledUsers');</code></p>
<p>&nbsp;</p>
<p><code>// Dimensions</code><br />
<code>$pageLocation = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$pageLocation-&gt;setName('pageLocation');</code></p>
<p>&nbsp;</p>
<p><code>$country = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$country-&gt;setName('country');</code></p>
<p>&nbsp;</p>
<p><code>$city = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$city-&gt;setName('city');</code></p>
<p>&nbsp;</p>
<p><code>$deviceCategory = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$deviceCategory-&gt;setName('deviceCategory');</code></p>
<p>&nbsp;</p>
<p><code>$browser = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$browser-&gt;setName('browser');</code></p>
<p>&nbsp;</p>
<p><code>$dateHourMinute = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$dateHourMinute-&gt;setName('dateHourMinute');</code></p>
<p>&nbsp;</p>
<p><code>$pageReferrer = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$pageReferrer-&gt;setName('pageReferrer');</code></p>
<p>&nbsp;</p>
<p><code>// Correct Custom Dimension Name with Prefix</code><br />
<code>$hashed_user_id = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$hashed_user_id-&gt;setName('customUser:hashed_user_id'); // Updated with correct dimension name</code></p>
<p>&nbsp;</p>
<p><code>$region = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$region-&gt;setName('region');</code></p>
<p>&nbsp;</p>
<p><code>// Create a RunReportRequest object</code><br />
<code>$request = new Google_Service_AnalyticsData_RunReportRequest();</code><br />
<code>$request-&gt;setDateRanges([$dateRange]);</code><br />
<code>$request-&gt;setMetrics([</code><br />
<code>$activeUsers, $averageSessionDuration, $sessions,</code><br />
<code>$screenPageViewsPerUser, $eventCount, $bounceRate,</code><br />
<code>$newUsers, $scrolledUsers</code><br />
<code>]);</code><br />
<code>$request-&gt;setDimensions([</code><br />
<code>$hashed_user_id, $dateHourMinute, $city, $region, $country, $deviceCategory, $browser,</code><br />
<code>$pageReferrer,$pageLocation</code><br />
<code>]);</code></p>
<p>&nbsp;</p>
<p><code>try {</code><br />
<code>$response = $analyticsData-&gt;properties-&gt;runReport("properties/$PROPERTY_ID", $request);</code><br />
<code>return $response;</code><br />
<code>} catch (Exception $e) {</code><br />
<code>// Capture the error message from the exception</code><br />
<code>$errorResponse = json_decode($e-&gt;getMessage(), true);</code></p>
<p>&nbsp;</p>
<p><code>if (isset($errorResponse['error']['message'])) {</code><br />
<code>$errorMessage = $errorResponse['error']['message'];</code><br />
<code>} else {</code><br />
<code>$errorMessage = 'An unknown error occurred.';</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>return $errorMessage; // Return the error message to be displayed</code><br />
<code>}</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>function printJsonResults($response, $errorMessage = null) {</code><br />
<code>$result = [</code><br />
<code>'code' =&gt; 200,</code><br />
<code>'status' =&gt; 'success',</code><br />
<code>'message' =&gt; '',</code><br />
<code>'data' =&gt; []</code><br />
<code>];</code></p>
<p>&nbsp;</p>
<p><code>if ($errorMessage) {</code><br />
<code>// If an error message is provided, show it in the response and set code to 500</code><br />
<code>$result['code'] = 500;</code><br />
<code>$result['status'] = 'error';</code><br />
<code>$result['message'] = $errorMessage;</code><br />
<code>} elseif (!$response) {</code><br />
<code>// If no response and no error, show generic error</code><br />
<code>$result['code'] = 500;</code><br />
<code>$result['status'] = 'error';</code><br />
<code>$result['message'] = 'No data to display due to a previous error.';</code><br />
<code>} elseif ($response-&gt;getRows()) {</code><br />
<code>foreach ($response-&gt;getRows() as $row) {</code><br />
<code>$dimensions = $row-&gt;getDimensionValues();</code><br />
<code>$metrics = $row-&gt;getMetricValues();</code></p>
<p><code>// Format dateHourMinute from "202409072020" to "2024-09-07 20:20"</code><br />
<code>$rawDateHourMinute = $dimensions[1]-&gt;getValue();</code><br />
<code>$formattedDateHourMinute = DateTime::createFromFormat('YmdHi', $rawDateHourMinute)-&gt;format('Y-m-d H:i');</code></p>
<p>&nbsp;</p>
<p><code>$result['data'][] = [</code><br />
<code>'hashed_user_id' =&gt; $dimensions[0]-&gt;getValue(),</code><br />
<code>'dateHourMinute' =&gt; $formattedDateHourMinute,</code><br />
<code>'city' =&gt; $dimensions[2]-&gt;getValue(),</code><br />
<code>'region' =&gt; $dimensions[3]-&gt;getValue(),</code><br />
<code>'country' =&gt; $dimensions[4]-&gt;getValue(),</code><br />
<code>'deviceCategory' =&gt; $dimensions[5]-&gt;getValue(),</code><br />
<code>'browser' =&gt; $dimensions[6]-&gt;getValue(),</code><br />
<code>'pageReferrer' =&gt; $dimensions[7]-&gt;getValue(),</code><br />
<code>'pageLocation' =&gt; $dimensions[8]-&gt;getValue(),</code><br />
<code>'activeUsers' =&gt; $metrics[0]-&gt;getValue(),</code><br />
<code>'averageSessionDuration' =&gt; $metrics[1]-&gt;getValue(),</code><br />
<code>'sessions' =&gt; $metrics[2]-&gt;getValue(),</code><br />
<code>'screenPageViewsPerUser' =&gt; $metrics[3]-&gt;getValue(),</code><br />
<code>'eventCount' =&gt; $metrics[4]-&gt;getValue(),</code><br />
<code>'bounceRate' =&gt; $metrics[5]-&gt;getValue(),</code><br />
<code>'newUsers' =&gt; $metrics[6]-&gt;getValue(),</code><br />
<code>'scrolledUsers' =&gt; $metrics[7]-&gt;getValue()</code><br />
<code>];</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>$result['message'] = 'Data successfully fetched.';</code><br />
<code>} else {</code><br />
<code>// If no rows are found, change status to "failed" and code to 404</code><br />
<code>$result['code'] = 404;</code><br />
<code>$result['status'] = 'failed';</code><br />
<code>$result['message'] = 'No rows found in the report.';</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>// Send the result as JSON</code><br />
<code>header('Content-Type: application/json');</code><br />
<code>echo json_encode($result, JSON_PRETTY_PRINT);</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>try {</code><br />
<code>$analyticsData = initializeAnalytics();</code><br />
<code>$response = getUserActivityReport($analyticsData);</code></p>
<p>&nbsp;</p>
<p><code>if (is_string($response)) {</code><br />
<code>// If the response is an error message, pass it to printJsonResults</code><br />
<code>printJsonResults(null, $response);</code><br />
<code>} else {</code><br />
<code>// Otherwise, pass the valid response to printJsonResults</code><br />
<code>printJsonResults($response);</code><br />
<code>}</code><br />
<code>} catch (Exception $e) {</code><br />
<code>// Extract the error message from the exception</code><br />
<code>$errorResponse = json_decode($e-&gt;getMessage(), true);</code></p>
<p>&nbsp;</p>
<p><code>if (isset($errorResponse['error']['message'])) {</code><br />
<code>printJsonResults(null, $errorResponse['error']['message']);</code><br />
<code>} else {</code><br />
<code>printJsonResults(null, 'An unknown error occurred.');</code><br />
<code>}</code><br />
<code>}</code><br />
<code>?&gt;</code></p>
<p>Output :</p>
<p><code>{</code><br />
<code>"code": 404,</code><br />
<code>"status": "failed",</code><br />
<code>"message": "No rows found in the report.",</code><br />
<code>"data": []</code><br />
<code>}</code></p>
<p><code>{</code><br />
<code>"code": 500,</code><br />
<code>"status": "error",</code><br />
<code>"message": "start_date must be less than or equal to end_date. start_date = 2024-09-08 and end_date = 2024-09-07",</code><br />
<code>"data": []</code><br />
<code>}</code></p>
<p>Output :<br />
<code>{</code><br />
<code>"code": 200,</code><br />
<code>"status": "success",</code><br />
<code>"message": "Data successfully fetched.",</code><br />
<code>"data": [</code><br />
<code>{</code><br />
<code>"hashed_user_id": "",</code><br />
<code>"dateHourMinute": "2024-09-07 14:43",</code><br />
<code>"city": "Patna",</code><br />
<code>"region": "Bihar",</code><br />
<code>"country": "India",</code><br />
<code>"deviceCategory": "desktop",</code><br />
<code>"browser": "Chrome",</code><br />
<code>"pageReferrer": "https:\/\/example.com\/login",</code><br />
<code>"pageLocation": "https:\/\/example.com\/dashboard",</code><br />
<code>"activeUsers": "3",</code><br />
<code>"averageSessionDuration": "1.23620225",</code><br />
<code>"sessions": "4",</code><br />
<code>"screenPageViewsPerUser": "0.33333333333333331",</code><br />
<code>"eventCount": "8",</code><br />
<code>"bounceRate": "1",</code><br />
<code>"newUsers": "0",</code><br />
<code>"scrolledUsers": "0"</code><br />
<code>}...</code><br />
<code>]</code><br />
<code>}</code></p>
<h3>Realtime Google Analytics Data Fetch Using Api php ?</h3>
<p><code></code></p>
<p><code>&lt;?php</code><br />
<code>$hashedUserID = 'ADMIN';</code><br />
<code>error_reporting(E_ALL);</code><br />
<code>ini_set('display_errors', 1);</code><br />
<code>require 'google_analytics/vendor/autoload.php';</code></p>
<p>&nbsp;</p>
<p><code>use Google\Client;</code><br />
<code>use Google\Service\AnalyticsData;</code></p>
<p>&nbsp;</p>
<p><code>function initializeAnalytics() {</code><br />
<code>$KEY_FILE_LOCATION = 'metal-sky-434809-n7-XXXXXXXXXXXXX.json'; // Path to your service account JSON key file</code></p>
<p>&nbsp;</p>
<p><code>$client = new Client();</code><br />
<code>$client-&gt;setAuthConfig($KEY_FILE_LOCATION);</code><br />
<code>$client-&gt;addScope(AnalyticsData::ANALYTICS_READONLY);</code></p>
<p>&nbsp;</p>
<p><code>return new AnalyticsData($client);</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>function getRealTimeReport($analyticsData, $hashedUserID) {</code><br />
<code>$PROPERTY_ID = '0000000000'; // Replace with your GA4 Property ID</code></p>
<p>&nbsp;</p>
<p><code>// Metrics</code><br />
<code>$activeUsers = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$activeUsers-&gt;setName('activeUsers');</code></p>
<p>&nbsp;</p>
<p><code>$screenPageViews = new Google_Service_AnalyticsData_Metric();</code><br />
<code>$screenPageViews-&gt;setName('screenPageViews');</code></p>
<p>&nbsp;</p>
<p><code>// Dimensions</code><br />
<code>$city = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$city-&gt;setName('city');</code></p>
<p>&nbsp;</p>
<p><code>$minutesAgo = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$minutesAgo-&gt;setName('minutesAgo');</code></p>
<p>&nbsp;</p>
<p><code>$deviceCategory = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$deviceCategory-&gt;setName('deviceCategory');</code></p>
<p>&nbsp;</p>
<p><code>// Custom dimension for 'hashed_user_id'</code><br />
<code>$hashedUserIDDimension = new Google_Service_AnalyticsData_Dimension();</code><br />
<code>$hashedUserIDDimension-&gt;setName('customUser:hashed_user_id'); // Correct dimension name</code></p>
<p>&nbsp;</p>
<p><code>// Create a RealtimeReportRequest object</code><br />
<code>$request = new Google_Service_AnalyticsData_RunRealtimeReportRequest();</code><br />
<code>$request-&gt;setMetrics([$activeUsers, $screenPageViews]);</code><br />
<code>$request-&gt;setDimensions([$city, $deviceCategory, $minutesAgo, $hashedUserIDDimension]); // Including hashed_user_id as a dimension</code></p>
<p><code>/*// Create the filter expression for the hashed user ID</code><br />
<code>$dimensionFilter = new Google_Service_AnalyticsData_Filter();</code><br />
<code>$dimensionFilter-&gt;setFieldName('customUser:hashed_user_id'); // Use the correct dimension name here</code><br />
<code>$dimensionFilter-&gt;setStringFilter(new Google_Service_AnalyticsData_StringFilter([</code><br />
<code>'matchType' =&gt; 'CONTAINS',///"CONTAINS" for specific word matching, "EXACT" means same to same match all</code><br />
<code>'value' =&gt; 'ADMIN'</code><br />
<code>]));</code></p>
<p>&nbsp;</p>
<p><code>$filterExpression = new Google_Service_AnalyticsData_FilterExpression();</code><br />
<code>$filterExpression-&gt;setFilter($dimensionFilter);</code></p>
<p>&nbsp;</p>
<p><code>// Set the dimension filter in the request</code><br />
<code>$request-&gt;setDimensionFilter($filterExpression);*/</code></p>
<p><code>try {</code><br />
<code>$response = $analyticsData-&gt;properties-&gt;runRealtimeReport("properties/$PROPERTY_ID", $request);</code><br />
<code>return $response;</code><br />
<code>} catch (Exception $e) {</code><br />
<code>echo 'Error fetching real-time report: ' . $e-&gt;getMessage() . "\n";</code><br />
<code>return null;</code><br />
<code>}</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>function printJsonResults($response) {</code><br />
<code>if (!$response) {</code><br />
<code>echo "No data to display due to previous error.\n";</code><br />
<code>return;</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>$data = [];</code></p>
<p>&nbsp;</p>
<p><code>if ($response-&gt;getRows()) {</code><br />
<code>foreach ($response-&gt;getRows() as $row) {</code><br />
<code>$dimensions = $row-&gt;getDimensionValues();</code><br />
<code>$metrics = $row-&gt;getMetricValues();</code></p>
<p>&nbsp;</p>
<p><code>$data[] = [</code><br />
<code>'hashed_user_id' =&gt; $dimensions[3]-&gt;getValue(),</code><br />
<code>'city' =&gt; $dimensions[0]-&gt;getValue(),</code><br />
<code>'deviceCategory' =&gt; $dimensions[1]-&gt;getValue(),</code><br />
<code>'minutesAgo' =&gt; $dimensions[2]-&gt;getValue(),</code><br />
<code>'activeUsers' =&gt; $metrics[0]-&gt;getValue(),</code><br />
<code>'screenPageViews' =&gt; $metrics[1]-&gt;getValue()</code><br />
<code>];</code><br />
<code>}</code><br />
<code>} else {</code><br />
<code>echo "No rows found in the real-time report.\n";</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>// Format the data for better readability and localization (if needed)</code><br />
<code>$formattedData = [];</code><br />
<code>foreach ($data as $row) {</code><br />
<code>$formattedRow = [];</code><br />
<code>foreach ($row as $key =&gt; $value) {</code><br />
<code>$formattedRow[$key] = localizeValue($value); // Function to localize values if needed</code><br />
<code>}</code><br />
<code>$formattedData[] = $formattedRow;</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>header('Content-Type: application/json');</code><br />
<code>echo json_encode($formattedData, JSON_PRETTY_PRINT);</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>function localizeValue($value) {</code><br />
<code>// Implement localization logic here if necessary</code><br />
<code>// Example: Convert dates to Indian date format, translate text, etc.</code><br />
<code>return $value;</code><br />
<code>}</code></p>
<p>&nbsp;</p>
<p><code>try {</code><br />
<code>$analyticsData = initializeAnalytics();</code><br />
<code>$hashedUserID = isset($hashedUserID) ? $hashedUserID : ''; // Ensure hashedUserID is defined</code><br />
<code>$response = getRealTimeReport($analyticsData, $hashedUserID);</code><br />
<code>printJsonResults($response);</code><br />
<code>} catch (Exception $e) {</code><br />
<code>echo 'Error: ' . $e-&gt;getMessage() . "\n";</code><br />
<code>}</code></p>
<p><strong>Api Output :</strong></p>
<p><code></code></p>
<pre><code>[
    {
        "hashed_user_id": "ADMIN:152.58.100.232",
        "city": "Jodhpur",
        "deviceCategory": "desktop",
        "minutesAgo": "01",
        "activeUsers": "1",
        "screenPageViews": "1"
    },
    {
        "hashed_user_id": "ADMIN:152.58.100.241",
        "city": "Jodhpur",
        "deviceCategory": "desktop",
        "minutesAgo": "01",
        "activeUsers": "1",
        "screenPageViews": "0"
    }
]
}</code></pre>
<p>&nbsp;</p><p>The post <a href="https://codinghelp.in/pixel-code-setup-in-own-website-with-google-analytics-facebook-pixel/">Pixel Code Setup in Own Website with Google Analytics, Facebook Pixel</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/pixel-code-setup-in-own-website-with-google-analytics-facebook-pixel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Aadhaar Number Validation javascript &#124; How to Validate Aadhaar Card Number in JavaScript Regex</title>
		<link>https://codinghelp.in/aadhaar-number-validation-javascript-how-to-validate-aadhaar-card-number-in-javascript-regex/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=aadhaar-number-validation-javascript-how-to-validate-aadhaar-card-number-in-javascript-regex</link>
					<comments>https://codinghelp.in/aadhaar-number-validation-javascript-how-to-validate-aadhaar-card-number-in-javascript-regex/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Mon, 26 Aug 2024 18:57:07 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=1038</guid>

					<description><![CDATA[<p>In the digital age, Aadhaar, India&#8217;s biometric identification system, has become a critical component in various online and offline services. Ensuring the validity of Aadhaar numbers is crucial for data integrity and security. This article delves into the nuances of Aadhaar number validation through web applications, providing a step-by-step guide to implementing a robust validation [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/aadhaar-number-validation-javascript-how-to-validate-aadhaar-card-number-in-javascript-regex/">Aadhaar Number Validation javascript | How to Validate Aadhaar Card Number in JavaScript Regex</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>In the digital age, Aadhaar, India&#8217;s biometric identification system, has become a critical component in various online and offline services. Ensuring the validity of Aadhaar numbers is crucial for data integrity and security. This article delves into the nuances of Aadhaar number validation through web applications, providing a step-by-step guide to implementing a robust validation mechanism using HTML, JavaScript, and jQuery.</p>
<p><strong>1. Understanding Aadhaar Number Validation</strong></p>
<p>Aadhaar numbers are 12-digit unique identifiers issued by the Indian government. To ensure that the numbers entered into a system are valid, we need to perform a series of checks:</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>Length Check</strong>: Aadhaar numbers must be exactly 12 digits long.</li>
<li><strong>Format Check</strong>: The number should not start with 0 or 1 and should be composed solely of digits.</li>
<li><strong>Checksum Validation</strong>: This is the most critical part, involving a checksum algorithm to verify the authenticity of the number.</li>
</ul>
</li>
</ul>
<p><strong>2. The Role of HTML and JavaScript</strong></p>
<p>To create an effective validation system, HTML is used for the user interface, while JavaScript handles the logic. In this example, we&#8217;ll use a combination of HTML, JavaScript, and jQuery to achieve a seamless user experience.</p>
<p><img loading="lazy" decoding="async" class="wp-image-1039 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/08/image-2.png" alt="" width="694" height="432" srcset="https://codinghelp.in/wp-content/uploads/2024/08/image-2.png 694w, https://codinghelp.in/wp-content/uploads/2024/08/image-2-300x187.png 300w" sizes="auto, (max-width: 694px) 100vw, 694px" /></p>
<p><strong>3. The HTML Structure</strong></p>
<p>The HTML structure for our validation system is straightforward. It includes:</p>
<ul>
<li>A text input field for entering the Aadhaar number.</li>
<li>A button to trigger the validation.</li>
<li>A div element to display error messages.</li>
</ul>
<p><strong>4. JavaScript for Validation</strong></p>
<p>The JavaScript code is responsible for validating the Aadhaar number. It performs several tasks:</p>
<ul>
<li><strong>Converts the input string to an integer array in reverse order.</strong></li>
<li><strong>Uses predefined arrays for checksum calculations.</strong></li>
<li><strong>Checks the length and format of the input.</strong></li>
<li><strong>Displays appropriate error messages based on validation results.</strong></li>
</ul>
<h1><span style="font-size: 18pt;">How to Validate Aadhaar Card Number in JavaScript Regex</span></h1>
<p>Complete  Script of Aadhaar Card Number Validation :</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;Aadhaar Number Validation&lt;/title&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"&gt;&lt;/script&gt;
    &lt;style&gt;
        #error_app_aadhaar {
            color: red;
            display: none;
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div&gt;
        &lt;label for="aadhaarNo"&gt;Aadhaar Number:&lt;/label&gt;
        &lt;input type="text" id="aadhaarNo" maxlength="12"&gt;
        &lt;button onclick="validateAadhaar()"&gt;Validate&lt;/button&gt;
        &lt;div id="error_app_aadhaar"&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;script&gt;
        // Validation data
        const d = [
            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
            [1, 2, 3, 4, 0, 6, 7, 8, 9, 5],
            [2, 3, 4, 0, 1, 7, 8, 9, 5, 6],
            [3, 4, 0, 1, 2, 8, 9, 5, 6, 7],
            [4, 0, 1, 2, 3, 9, 5, 6, 7, 8],
            [5, 9, 8, 7, 6, 0, 4, 3, 2, 1],
            [6, 5, 9, 8, 7, 1, 0, 4, 3, 2],
            [7, 6, 5, 9, 8, 2, 1, 0, 4, 3],
            [8, 7, 6, 5, 9, 3, 2, 1, 0, 4],
            [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
        ];
        const p = [
            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
            [1, 5, 7, 6, 2, 8, 3, 0, 9, 4],
            [5, 8, 0, 3, 7, 9, 6, 1, 4, 2],
            [8, 9, 1, 6, 0, 4, 3, 5, 2, 7],
            [9, 4, 5, 3, 1, 2, 6, 8, 7, 0],
            [4, 2, 8, 6, 5, 7, 3, 9, 0, 1],
            [2, 7, 9, 3, 8, 0, 6, 4, 1, 5],
            [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]
        ];
        const inv = [0, 4, 3, 2, 1, 5, 6, 7, 8, 9];

        // Convert the input string to a reversed integer array
        function stringToReversedIntArray(inputtxt) {
            return inputtxt.split('').reverse().map(Number);
        }

        // Validate Aadhaar number using checksum algorithm
        function isValidAadhaar(inputtxt) {
            let c = 0;
            const myArray = stringToReversedIntArray(inputtxt);
            for (let i = 0; i &lt; myArray.length; i++) {
                c = d[c][p[i % 8][myArray[i]]];
            }
            return c === 0;
        }

        function validateAadhaar() {
            // Get Aadhaar number from the input field
            var inputtxt = $('#aadhaarNo').val().trim();

            // Basic validation
            if (!inputtxt) {
                $('#error_app_aadhaar').text("Aadhaar number is mandatory.");
                $('#error_app_aadhaar').show();
                return false;
            }

            // Validate length and format
            const numbers = /^[2-9]\d{11}$/; // Must be 12 digits, not starting with 0 or 1
            if (inputtxt.length !== 12) {
                $('#error_app_aadhaar').text("Aadhaar number length should be 12 digits.");
                $('#error_app_aadhaar').show();
                return false;
            }
            if (!inputtxt.match(numbers)) {
                $('#error_app_aadhaar').text("Invalid Aadhaar number format.");
                $('#error_app_aadhaar').show();
                return false;
            }

            // Check for valid Aadhaar
            if (!isValidAadhaar(inputtxt)) {
                $('#error_app_aadhaar').text("Provided Aadhaar is invalid. Kindly enter a correct Aadhaar.");
                $('#error_app_aadhaar').show();
                return false;
            }

            // Hide error message if valid
            $('#error_app_aadhaar').hide();

            // Set encrypted values (assuming getfunctionalValue is defined elsewhere)
            $('#aadhaarEncrypt').val(getfunctionalValue(inputtxt));

            return true;
        }

        // Placeholder function for encryption (replace with actual logic if needed)
        function getfunctionalValue(value) {
            return value; // Replace with actual encryption logic if required
        }
    &lt;/script&gt;

    &lt;!-- Hidden fields for encrypted values --&gt;
    &lt;input type="hidden" id="aadhaarEncrypt"&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<div class="overflow-y-auto p-4" dir="ltr">
<pre><strong style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">5. Error Handling and User Feedback</strong></pre>
</div>
<p>Proper error handling is essential for a good user experience. In the provided code:</p>
<ul>
<li><strong>Mandatory Field Check</strong>: Ensures that the user has entered something.</li>
<li><strong>Length and Format Validation</strong>: Ensures the number meets the required criteria.</li>
<li><strong>Checksum Validation</strong>: Uses an algorithm to verify the authenticity.</li>
</ul>
<p><strong>6. Integrating Encryption</strong></p>
<p>In real-world scenarios, Aadhaar numbers often need to be encrypted for security. The placeholder function <code>getfunctionalValue</code> in the code should be replaced with actual encryption logic, depending on the encryption requirements of your application.</p>
<p><strong>7. Best Practices for Aadhaar Validation</strong></p>
<ul>
<li><strong>Secure Transmission</strong>: Always use HTTPS to ensure secure transmission of Aadhaar numbers.</li>
<li><strong>Data Privacy</strong>: Handle Aadhaar numbers with utmost care, adhering to data protection regulations.</li>
<li><strong>Regular Updates</strong>: Keep validation logic updated according to any changes in Aadhaar number validation rules.</li>
</ul>
<p><strong>8. Conclusion</strong></p>
<p>Implementing Aadhaar number validation is a crucial step in ensuring the integrity and security of user data in web applications. By following the guidelines and using the provided code, developers can create a robust validation mechanism that handles various validation scenarios effectively.</p>
<p>Incorporating this validation process into your web application not only improves user experience but also strengthens the security and reliability of your system. As technology and regulations evolve, staying informed and updating your validation logic will help maintain the effectiveness of your validation system.</p><p>The post <a href="https://codinghelp.in/aadhaar-number-validation-javascript-how-to-validate-aadhaar-card-number-in-javascript-regex/">Aadhaar Number Validation javascript | How to Validate Aadhaar Card Number in JavaScript Regex</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/aadhaar-number-validation-javascript-how-to-validate-aadhaar-card-number-in-javascript-regex/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PHP Script for Decryption or Encryption in AES-256-CBC</title>
		<link>https://codinghelp.in/php-script-for-decryption-or-encryption-in-aes-256-cbc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-script-for-decryption-or-encryption-in-aes-256-cbc</link>
					<comments>https://codinghelp.in/php-script-for-decryption-or-encryption-in-aes-256-cbc/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Wed, 21 Aug 2024 13:04:26 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=1034</guid>

					<description><![CDATA[<p>By using the same function for both encryption and decryption, you can verify if the issue lies with the data or the decryption process itself. the function openssl_decrypt() will work on the server if the OpenSSL extension is installed and enabled in PHP. The OpenSSL extension is typically included in most PHP installations by default, [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/php-script-for-decryption-or-encryption-in-aes-256-cbc/">PHP Script for Decryption or Encryption in AES-256-CBC</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="flex max-w-full flex-col flex-grow">
<div class="min-h-[20px] text-message flex w-full flex-col items-end gap-2 break-words [.text-message+&amp;]:mt-5 overflow-x-auto whitespace-pre-wrap" dir="auto" data-message-author-role="assistant" data-message-id="63a3cef8-2cd4-4b72-9e5f-76ddb97c7b1d">
<div class="flex w-full flex-col gap-1 empty:hidden first:pt-[3px]">
<div class="markdown prose w-full break-words dark:prose-invert light">
<p>By using the same function for both encryption and decryption, you can verify if the issue lies with the data or the decryption process itself. the function <code>openssl_decrypt()</code> will work on the server if the OpenSSL extension is installed and enabled in PHP. The OpenSSL extension is typically included in most PHP installations by default, but it may need to be enabled explicitly in the server configuration.</p>
<h3>Here&#8217;s how you can ensure <code>openssl_decrypt()</code> works on your server:</h3>
<ol>
<li><strong>Check if OpenSSL is installed</strong>:
<ul>
<li>You can check if the OpenSSL extension is enabled in PHP by running the following command in your terminal or by creating a PHP file with the following content:</li>
</ul>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md">php</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-meta">&lt;?php</span><br />
<span class="hljs-title function_ invoke__">phpinfo</span>();<br />
<span class="hljs-meta">?&gt;</span><br />
</code></div>
</div>
<p><img loading="lazy" decoding="async" class="wp-image-1035 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/08/image.png" alt="" width="911" height="207" srcset="https://codinghelp.in/wp-content/uploads/2024/08/image.png 911w, https://codinghelp.in/wp-content/uploads/2024/08/image-300x68.png 300w, https://codinghelp.in/wp-content/uploads/2024/08/image-768x175.png 768w" sizes="auto, (max-width: 911px) 100vw, 911px" /><br />
Look for a section named <strong>OpenSSL</strong> in the output. If it&#8217;s there, the extension is installed and enabled.</li>
<li><strong>Enable OpenSSL (if not enabled)</strong>:
<ul>
<li>If the OpenSSL extension is not enabled, you can enable it by editing your <code>php.ini</code> file. Look for the following line and ensure it&#8217;s uncommented:</li>
</ul>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md">ini</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-ini"><span class="hljs-attr">extension</span>=openssl<br />
</code></div>
</div>
<p>After making this change, restart your web server (e.g., Apache or Nginx) for the changes to take effect.</li>
<li><strong>Error Handling</strong>:
<ul>
<li>It&#8217;s a good idea to include error handling to ensure that if decryption fails, you get informative error messages. You can modify the decryption function like this:</li>
</ul>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md">php</div>
<div class="overflow-y-auto p-4" dir="ltr">
<p><code>&lt;?php</code><br />
<code>function encrypt($data, $passphrase) {</code><br />
<code>$salt = openssl_random_pseudo_bytes(8);</code><br />
<code>$salted = $dx = '';</code><br />
<code>while (strlen($salted) &lt; 48) {</code><br />
<code>$dx = md5($dx . $passphrase . $salt, true);</code><br />
<code>$salted .= $dx;</code><br />
<code>}</code><br />
<code>$key = substr($salted, 0, 32);</code><br />
<code>$iv = substr($salted, 32, 16);</code><br />
<code>$encrypted_data = openssl_encrypt($data, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);</code><br />
<code>return base64_encode('Salted__' . $salt . $encrypted_data);</code><br />
<code>}</code></p>
<p><code>function decrypt($encrypted, $passphrase) {</code><br />
<code>$encrypted = base64_decode($encrypted);</code><br />
<code>if (substr($encrypted, 0, 8) !== 'Salted__') {</code><br />
<code>return "Invalid encrypted data format";</code><br />
<code>}</code><br />
<code>$salt = substr($encrypted, 8, 8);</code><br />
<code>$encrypted = substr($encrypted, 16);</code><br />
<code>$salted = $dx = '';</code><br />
<code>while (strlen($salted) &lt; 48) {</code><br />
<code>$dx = md5($dx . $passphrase . $salt, true);</code><br />
<code>$salted .= $dx;</code><br />
<code>}</code><br />
<code>$key = substr($salted, 0, 32);</code><br />
<code>$iv = substr($salted, 32, 16);</code><br />
<code>$decrypted = openssl_decrypt($encrypted, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);</code><br />
<code>if ($decrypted === false) {</code><br />
<code>return "Decryption failed: " . openssl_error_string();</code><br />
<code>}</code><br />
<code>return $decrypted;</code><br />
<code>}</code></p>
<p><code>// Test encryption and decryption</code><br />
<code>$test_data = "Hello, OpenSSL!";</code><br />
<code>$passphrase = "gHDI:#bV8a-fo9x4W5Ly";</code></p>
<p><code>// Encrypt the data</code><br />
<code>$encrypted_data = encrypt($test_data, $passphrase);</code><br />
<code>echo "Encrypted Data: " . $encrypted_data . "\n";</code></p>
<p><code>// Decrypt the data</code><br />
<code>$decrypted_data = decrypt($encrypted_data, $passphrase);</code><br />
<code>echo "Decrypted Data: " . $decrypted_data . "\n";</code><br />
<code>?&gt;</code></p>
</div>
</div>
</li>
</ol>
<h3>Output :</h3>
<p><img loading="lazy" decoding="async" class="wp-image-1036 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/08/image-1.png" alt="" width="772" height="92" srcset="https://codinghelp.in/wp-content/uploads/2024/08/image-1.png 772w, https://codinghelp.in/wp-content/uploads/2024/08/image-1-300x36.png 300w, https://codinghelp.in/wp-content/uploads/2024/08/image-1-768x92.png 768w" sizes="auto, (max-width: 772px) 100vw, 772px" /></p>
<h3>Explanation:</h3>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong><code>phpinfo()</code></strong>: This PHP function will print detailed information about your PHP configuration, including enabled extensions like OpenSSL.</li>
</ul>
</li>
</ul>
<ul>
<li><strong>OpenSSL Extension</strong>: OpenSSL is required for functions like <code>openssl_encrypt()</code> and <code>openssl_decrypt()</code> to work. This extension provides a variety of cryptographic functions.</li>
<li><strong>Error Handling</strong>: It&#8217;s good practice to handle potential decryption errors by checking if <code>openssl_decrypt()</code> returns <code>false</code> and then outputting an error message.</li>
</ul>
<h3>What to do if OpenSSL is not installed:</h3>
<p>If OpenSSL is not installed or enabled, you&#8217;ll need to enable it or contact your hosting provider to enable it for you.</p>
</div>
</div>
</div>
</div>
<div class="mt-1 flex gap-3 empty:hidden -ml-2">
<div class="items-center justify-start rounded-xl p-1 z-10 -mt-1 bg-token-main-surface-primary md:absolute md:border md:border-token-border-light md:hidden">
<div class="flex items-center">
<div class="flex items-center pb-0">
<div class="[&amp;_svg]:h-full [&amp;_svg]:w-full icon-md h-4 w-4"></div>
</div>
</div>
</div>
</div><p>The post <a href="https://codinghelp.in/php-script-for-decryption-or-encryption-in-aes-256-cbc/">PHP Script for Decryption or Encryption in AES-256-CBC</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/php-script-for-decryption-or-encryption-in-aes-256-cbc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Store Files on Google Cloud Storage Using PHP</title>
		<link>https://codinghelp.in/how-to-store-files-on-google-cloud-storage-using-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-store-files-on-google-cloud-storage-using-php</link>
					<comments>https://codinghelp.in/how-to-store-files-on-google-cloud-storage-using-php/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Sat, 15 Jun 2024 12:36:03 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=1020</guid>

					<description><![CDATA[<p>Storing files on Google Cloud Storage (GCS) using PHP is a straightforward process, thanks to the Google Cloud PHP Client Library. This guide will walk you through the steps to upload files to GCS and generate a signed URL for accessing the files. Google Cloud Storage provides a flexible object storage that can be accessed [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/how-to-store-files-on-google-cloud-storage-using-php/">How to Store Files on Google Cloud Storage Using PHP</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Storing files on Google Cloud Storage (GCS) using PHP is a straightforward process, thanks to the Google Cloud PHP Client Library. This guide will walk you through the steps to upload files to GCS and generate a signed URL for accessing the files.</p>
<p>Google Cloud Storage provides a flexible object storage that can be accessed from PHP in different ways. Each of these implementations has its benefits and downsides.</p>
<p>Google Cloud Storage (GCS) is a service that provides cheap and massive object storage, where objects are simply chunks of data such as file contents. This makes GCS suitable for applications like backups, web hosting, media file storage, content delivery networks, data lakes, etc. Being able to access GCS from PHP applications and scripts creates a lot of possibilities for companies and organisations that rely on a PHP code base and knowledge.</p>
<p>Streams have been part of PHP for a long time now. They are a generalization of file, network and other data stream operations, and they use so-called wrappers to implement specific protocols and encodings. If you ever wondered why you could do a file_get_contents on a URL, wonder no more. HTTP is just another protocol implemented in a stream wrapper. The PHP package that Google provides for GCS access includes a stream wrapper that can be registered, allowing GCS access through regular PHP stream functions like fopen or file_get_contents.</p>
<p><img loading="lazy" decoding="async" class="wp-image-1026 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/06/image-46.png" alt="" width="640" height="304" srcset="https://codinghelp.in/wp-content/uploads/2024/06/image-46.png 1069w, https://codinghelp.in/wp-content/uploads/2024/06/image-46-300x143.png 300w, https://codinghelp.in/wp-content/uploads/2024/06/image-46-1024x487.png 1024w, https://codinghelp.in/wp-content/uploads/2024/06/image-46-768x365.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<h1><span style="font-size: 18pt;">How to Store Files on Google Cloud Storage Using PHP</span></h1>
<p>Creating a Firebase project involves several steps, including setting up your Firebase project in the Firebase console, configuring your app, and integrating Firebase services. Here’s a detailed guide on how to do it:</p>
<h3>Step 1: Create a Firebase Project</h3>
<ol>
<li><strong>Go to Firebase Console:</strong>
<ul>
<li>Navigate to the <span style="color: #0000ff;"><strong><a style="color: #0000ff;" href="https://console.firebase.google.com/" target="_new" rel="noreferrer noopener">Firebase Console</a></strong></span>.</li>
</ul>
</li>
<li><strong>Add a Project:</strong>
<ul>
<li>Click on the &#8220;<strong>Add project</strong>&#8221; button.<br />
<img loading="lazy" decoding="async" class="wp-image-1022 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/06/image-42.png" alt="" width="485" height="209" srcset="https://codinghelp.in/wp-content/uploads/2024/06/image-42.png 847w, https://codinghelp.in/wp-content/uploads/2024/06/image-42-300x129.png 300w, https://codinghelp.in/wp-content/uploads/2024/06/image-42-768x331.png 768w" sizes="auto, (max-width: 485px) 100vw, 485px" /></li>
</ul>
</li>
<li><strong>Project Name:</strong>
<ul>
<li>Enter a project name. This will be the identifier for your project across Firebase and Google Cloud.</li>
<li>Click &#8220;Continue&#8221;.</li>
</ul>
</li>
<li><strong>Google Analytics:</strong>
<ul>
<li>You can enable Google Analytics for your project. This step is optional but recommended for tracking user engagement.</li>
<li>If you enable it, you will need to configure your Analytics settings.</li>
</ul>
</li>
<li><strong>Configure Project Settings:</strong>
<ul>
<li>Select your Analytics location and agree to the Firebase terms.</li>
<li>Click &#8220;Create project&#8221;.</li>
</ul>
</li>
<li><strong>Project Creation:</strong>
<ul>
<li>Firebase will set up your project. This may take a few moments.</li>
<li>Once completed, click &#8220;Continue&#8221; to be redirected to your new Firebase project dashboard.</li>
</ul>
</li>
</ol>
<h2>How to Download Firebase credentials JSON</h2>
<p>To generate the <code>firebase_credentials.json</code> file, which contains the service account credentials for Firebase, follow these steps:</p>
<h3>Step 1: Navigate to Firebase Project Settings</h3>
<ol>
<li><strong>Go to Firebase Console:</strong>
<ul>
<li>Navigate to the <strong><a target="_new" rel="noreferrer noopener">Firebase Console</a></strong>.</li>
</ul>
</li>
<li><strong>Select Your Project:</strong>
<ul>
<li>Click on the project for which you want to generate the credentials.</li>
</ul>
</li>
<li><strong>Open Project Settings:</strong>
<ul>
<li>Click on the gear icon next to &#8220;<strong>Project Overview</strong>&#8221; in the sidebar.</li>
<li>Select &#8220;Project settings&#8221; from the dropdown menu.<br />
<img loading="lazy" decoding="async" class="wp-image-1023 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/06/image-43.png" alt="" width="682" height="263" srcset="https://codinghelp.in/wp-content/uploads/2024/06/image-43.png 951w, https://codinghelp.in/wp-content/uploads/2024/06/image-43-300x116.png 300w, https://codinghelp.in/wp-content/uploads/2024/06/image-43-768x296.png 768w" sizes="auto, (max-width: 682px) 100vw, 682px" /></li>
</ul>
</li>
</ol>
<h3>Step 2: Create a Service Account</h3>
<ol>
<li><strong>Go to Service Accounts:</strong>
<ul>
<li>In the Project settings page, click on the &#8220;<strong>Service accounts</strong>&#8221; tab.</li>
</ul>
</li>
<li><strong>Generate a New Private Key:</strong>
<ul>
<li>Click on the &#8220;<strong>Generate new private key</strong>&#8221; button.</li>
<li>A prompt will appear, asking for confirmation to generate a new private key.<br />
<img loading="lazy" decoding="async" class="wp-image-1024 alignnone " src="https://codinghelp.in/wp-content/uploads/2024/06/image-44.png" alt="" width="665" height="406" srcset="https://codinghelp.in/wp-content/uploads/2024/06/image-44.png 951w, https://codinghelp.in/wp-content/uploads/2024/06/image-44-300x183.png 300w, https://codinghelp.in/wp-content/uploads/2024/06/image-44-768x469.png 768w" sizes="auto, (max-width: 665px) 100vw, 665px" /></li>
</ul>
</li>
<li><strong>Download the JSON File:</strong>
<ul>
<li>Confirm the action, and a JSON file containing your service account credentials will be downloaded to your computer. This file is typically named <code>project-id-firebase-adminsdk-xxxxx-xxxxxxxxxx.json</code>.</li>
</ul>
</li>
</ol>
<h3>Step 3: Rename and Secure the File</h3>
<ol>
<li><strong>Rename the File:</strong>
<ul>
<li>Rename the downloaded JSON file to <code>firebase_credentials.json</code> (or any other preferred name).</li>
</ul>
</li>
<li><strong>Secure the File:</strong>
<ul>
<li>Store this file securely, as it contains sensitive information that grants access to your Firebase project. Ensure it&#8217;s not exposed in your source code repository by adding it to <code>.gitignore</code> or similar ignore files.</li>
</ul>
</li>
</ol>
<h3></h3>
<h2>kreait/firebase-php library download</h2>
<p>To store a PDF file in Firebase Storage using PHP, you&#8217;ll need to follow these steps:</p>
<h3>Prerequisites</h3>
<ol>
<li><strong>Firebase Project</strong>: Ensure you have created a Firebase project and set up Firebase Storage.</li>
<li><strong>Firebase SDK</strong>: Include Firebase SDK for PHP in your project. You can install it via Composer:
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md"></div>
<div class="overflow-y-auto p-4" dir="ltr"><span style="color: #00ff00;"><strong><code class="!whitespace-pre hljs language-bash">composer require kreait/firebase-php<br />
</code></strong></span></div>
</div>
<p>If you haven&#8217;t used Composer before, you&#8217;ll need to set up <code>composer.json</code> and run <code>composer install</code> to install dependencies.</li>
<li><strong>Service Account</strong>: Download the service account JSON file from Firebase Console (<code>Settings &gt; Service Accounts</code>). This JSON file contains credentials that allow your PHP script to authenticate with Firebase.</li>
</ol>
<h3></h3>
<h3>How to Upload Files to Firebase Storage Using PHP</h3>
<p>In this article, we’ll go through the process of uploading files to Firebase Storage using PHP. We’ll use the Firebase Admin SDK for PHP, specifically the Kreait Firebase PHP SDK, to handle the upload and generate a signed URL for downloading the file.</p>
<h4>Prerequisites</h4>
<p>Before you start, ensure you have the following:</p>
<ol>
<li><strong>Firebase Project</strong>: Set up a Firebase project in the Firebase Console.</li>
<li><strong>Service Account Key</strong>: Download the JSON file for your service account from the Firebase Console.</li>
<li><strong>Composer</strong>: PHP dependency manager installed on your system.</li>
</ol>
<h4>Step 1: Install the Firebase PHP SDK</h4>
<p>First, you need to install the Firebase PHP SDK via Composer. If you don’t have Composer installed, you can download it from <a href="https://getcomposer.org/" target="_new" rel="noreferrer noopener">getcomposer.org</a>.</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-bash">composer require kreait/firebase-php<br />
</code></div>
</div>
<h4>Step 2: Prepare Your PHP Script</h4>
<p>Create a PHP script to handle the file upload. In this example, we’ll name it <code>upload.php</code>.</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-meta">&lt;?php</span><br />
<span class="hljs-title function_ invoke__">error_reporting</span>(E_ALL);<br />
<span class="hljs-title function_ invoke__">ini_set</span>(<span class="hljs-string">'display_errors'</span>, 1);</p>
<p><span class="hljs-keyword">require</span> <span class="hljs-string">'vendor/autoload.php'</span>; <span class="hljs-comment">// Path to Composer autoload</span></p>
<p><span class="hljs-keyword">use</span> <span class="hljs-title">Kreait</span>\<span class="hljs-title">Firebase</span>\<span class="hljs-title">Factory</span>;</p>
<p><span class="hljs-comment">// Path to your JSON key file</span><br />
<span class="hljs-variable">$serviceAccountPath</span> = <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/serviceAccountKey.json'</span>; <span class="hljs-comment">// Update with the correct path</span></p>
<p><span class="hljs-comment">// Initialize Firebase using the Factory class with the JSON key file</span><br />
<span class="hljs-variable">$factory</span> = (<span class="hljs-keyword">new</span> <span class="hljs-title class_">Factory</span>)-&gt;<span class="hljs-title function_ invoke__">withServiceAccount</span>(<span class="hljs-variable">$serviceAccountPath</span>);</p>
<p><span class="hljs-variable">$storage</span> = <span class="hljs-variable">$factory</span>-&gt;<span class="hljs-title function_ invoke__">createStorage</span>();</p>
<p><span class="hljs-comment">// File to upload</span><br />
<span class="hljs-variable">$file</span> = <span class="hljs-string">'230595060707_Cert.pdf'</span>; <span class="hljs-comment">// Replace with the path to your file</span></p>
<p><span class="hljs-comment">// Ensure the file exists</span><br />
<span class="hljs-keyword">if</span> (!<span class="hljs-title function_ invoke__">file_exists</span>(<span class="hljs-variable">$file</span>)) {<br />
    <span class="hljs-keyword">die</span>(<span class="hljs-string">"File not found: <span class="hljs-subst">$file</span>"</span>);<br />
}</p>
<p><span class="hljs-comment">// Storage bucket and destination in Firebase Storage</span><br />
<span class="hljs-variable">$bucket</span> = <span class="hljs-variable">$storage</span>-&gt;<span class="hljs-title function_ invoke__">getBucket</span>();<br />
<span class="hljs-variable">$object</span> = <span class="hljs-variable">$bucket</span>-&gt;<span class="hljs-title function_ invoke__">upload</span>(<span class="hljs-title function_ invoke__">file_get_contents</span>(<span class="hljs-variable">$file</span>), [<br />
    <span class="hljs-string">'name'</span> =&gt; <span class="hljs-string">'cloudstore/'</span> . <span class="hljs-title function_ invoke__">basename</span>(<span class="hljs-variable">$file</span>)<br />
]);</p>
<p><span class="hljs-comment">// Set the expiration date and time for the signed URL</span><br />
<span class="hljs-variable">$expirationDateTime</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">\DateTime</span>();<br />
<span class="hljs-variable">$expirationDateTime</span>-&gt;<span class="hljs-title function_ invoke__">modify</span>(<span class="hljs-string">'+1 minutes'</span>); <span class="hljs-comment">// Set the URL to expire in 1 minute</span></p>
<p><span class="hljs-comment">// Get the download URL of the uploaded file with the expiration date</span><br />
<span class="hljs-variable">$downloadUrl</span> = <span class="hljs-variable">$object</span>-&gt;<span class="hljs-title function_ invoke__">signedUrl</span>(<span class="hljs-variable">$expirationDateTime</span>);</p>
<p><span class="hljs-keyword">echo</span> <span class="hljs-string">"File uploaded successfully. Download URL: <span class="hljs-subst">$downloadUrl</span>"</span>;<br />
<span class="hljs-meta">?&gt;</span><br />
</code></div>
</div>
<h4><img loading="lazy" decoding="async" class="wp-image-1025 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/06/image-45.png" alt="" width="961" height="199" srcset="https://codinghelp.in/wp-content/uploads/2024/06/image-45.png 961w, https://codinghelp.in/wp-content/uploads/2024/06/image-45-300x62.png 300w, https://codinghelp.in/wp-content/uploads/2024/06/image-45-768x159.png 768w" sizes="auto, (max-width: 961px) 100vw, 961px" /></h4>
<p><span style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">https://storage.googleapis.com/cloudstorageshop.appspot.com/cloudstore/1448433098ezgif-7-edd9bccb95.gif?GoogleAccessId=firebase-adminsdk-bzbmp%40cloudstorageshop.iam.gserviceaccount.com&amp;Expires=1718453016&amp;Signature=D5QzQS1kDCFZzgavmyP5YpO6V8WiGrhqCSgh21xJDb5YrYtCqTnUNMvcPK</span></p>
<h4>Step 3: Configure Firebase</h4>
<p>To use the Firebase Admin SDK, you need to create a service account in your Firebase project and download the service account key JSON file.</p>
<ol>
<li>Go to the <a target="_new" rel="noreferrer noopener">Firebase Console</a>.</li>
<li>Select your project.</li>
<li>Click the gear icon next to “Project Overview” and select “Project settings”.</li>
<li>Go to the “Service accounts” tab.</li>
<li>Click “Generate new private key” and download the JSON file.</li>
<li>Save the JSON file in your project directory and update the <code>$serviceAccountPath</code> in your script with the correct path.</li>
</ol>
<h4>Step 4: Upload the File</h4>
<p>Ensure the file you want to upload exists in your project directory or specify the correct path to the file in the <code>$file</code> variable. In this example, we’re using a file named <code>230595060707_Cert.pdf</code>.</p>
<h4>Explanation</h4>
<ol>
<li><strong>Error Reporting</strong>: Enables error reporting for debugging purposes.</li>
<li><strong>Autoload</strong>: Requires the Composer autoload file to load dependencies.</li>
<li><strong>Firebase Initialization</strong>: Uses the <code>Factory</code> class to initialize Firebase with the service account credentials.</li>
<li><strong>File Upload</strong>: Reads the file and uploads it to Firebase Storage under the <code>cloudstore/</code> directory.</li>
<li><strong>Signed URL</strong>: Generates a signed URL that allows users to download the file within a specified time frame (1 minute in this case).</li>
</ol>
<p>This script demonstrates a basic file upload to Firebase Storage using PHP. You can modify it to suit your specific needs, such as handling different file types, adjusting the expiration time, or adding error handling and logging.</p>
<h2>File Upload and Delete in google firebase storage full source code download</h2>
<p>All Complete Source Code Link : <a href="https://codinghelp.in/wp-content/uploads/2024/06/googlestoragesource.zip">googlestoragesource</a></p>
<p>File Upload and Delete in google firebase storage full source code download below :</p>
<p><strong><a href="https://codinghelp.in/wp-content/uploads/2024/06/googlestoragesource.zip">Click Here</a></strong></p><p>The post <a href="https://codinghelp.in/how-to-store-files-on-google-cloud-storage-using-php/">How to Store Files on Google Cloud Storage Using PHP</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/how-to-store-files-on-google-cloud-storage-using-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Login with Google using JavaScript and PHP Pop Up</title>
		<link>https://codinghelp.in/login-with-google-using-javascript-and-php-pop-up/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=login-with-google-using-javascript-and-php-pop-up</link>
					<comments>https://codinghelp.in/login-with-google-using-javascript-and-php-pop-up/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Tue, 23 Jan 2024 16:52:59 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=938</guid>

					<description><![CDATA[<p>Login with Google using JavaScript and PHP Pop Up &#8211; In the past, I have written an article on Google Login integration with PHP. Following that article, when a user clicks on the login button they will redirect to Google’s website for login, and after completing the authentication they’ll redirect back to your website. During [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/login-with-google-using-javascript-and-php-pop-up/">Login with Google using JavaScript and PHP Pop Up</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Login with Google using JavaScript and PHP Pop Up &#8211; In the past, I have written an article on Google Login integration with PHP. Following that article, when a user clicks on the login button they will redirect to Google’s website for login, and after completing the authentication they’ll redirect back to your website.</p>
<p>During the login process, your users are away from your website for a while until they complete the Google authentication.</p>
<p>If you don’t want to redirect users to the Google login page then another option is to show the Google login popup within your application. The user will enter their credentials in the modal window and on successful authentication, log in to your system.</p>
<p>It adds a better user experience to your login flow as everything happens in the modal window without leaving your website.</p>
<p>In this article, we study how to build a Google login popup using JavaScript and log the user in with the help of PHP. We also store the user details in the database that can be used in the application.</p>
<h1><span style="font-size: 14pt;">How to get client id and secret key with </span><span style="font-size: 14pt;">Could Console </span><span style="font-size: 14pt;">&#8211; console.cloud.google.com</span></h1>
<ul class="step_list">
<li>Go to the <a href="https://console.cloud.google.com/welcome?hl=fr" target="_blank" rel="noopener noreferrer">Google API Console</a>.</li>
<li>Select an existing project from the projects list, or click <b>NEW PROJECT</b> to create a new project:
<ul class="bullet_disk_list">
<li>Enter the <b>Project Name</b>. (You can enter the name of your website)</li>
<li><img loading="lazy" decoding="async" class="alignnone wp-image-345" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1.png" alt="" width="536" height="320" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1.png 1079w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-300x179.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-1024x611.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-768x458.png 768w" sizes="auto, (max-width: 536px) 100vw, 536px" /></li>
<li>Under the Project Name, you will see the Google API console automatically creates a project ID. Optionally you can change this project ID by the <b>Edit</b> link. But project ID must be unique worldwide.</li>
<li>Click on the <b>CREATE</b> button and the project will be created in some seconds.</li>
</ul>
</li>
<li>In the left side navigation panel, select <b>Credentials</b> under the <b>APIs &amp; Services</b> section.</li>
<li>Select the <b>OAuth consent screen</b> tab, specify the consent screen settings.
<ul class="bullet_disk_list">
<li>In <b>Application name</b> field, enter the name of your Application.</li>
<li>In <b>Support email</b> filed, choose an email address for user support.</li>
<li>In the <b>Authorized domains</b>, specify the domains which will be allowed to authenticate using OAuth.</li>
<li>Click the <b>Save</b> button.
<ul>
<li><img loading="lazy" decoding="async" class="alignnone size-full wp-image-346" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2.png" alt="" width="909" height="614" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2.png 909w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2-300x203.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2-768x519.png 768w" sizes="auto, (max-width: 909px) 100vw, 909px" /></li>
<li>Click On Publish App button (If you do not publish this, your visitor cannot log in, please remember this and publish it.)</li>
</ul>
</li>
</ul>
</li>
<li>Select the <b>Credentials</b> tab, click the <b>Create credentials</b> drop-down and select <b>OAuth client ID</b>.
<ul class="bullet_disk_list">
<li><img loading="lazy" decoding="async" class="alignnone size-full wp-image-347" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3.png" alt="" width="1059" height="514" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3.png 1059w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-300x146.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-1024x497.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-768x373.png 768w" sizes="auto, (max-width: 1059px) 100vw, 1059px" /></li>
<li>In the <b>Application type</b> section, select <b>Web application</b>.</li>
<li>in the <strong>Name</strong> Enter Your Project Name</li>
<li><img loading="lazy" decoding="async" class="wp-image-924 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/01/image-1.png" alt="" width="640" height="371" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-1.png 1107w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-300x174.png 300w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-1024x594.png 1024w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-768x445.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>In the <strong>Allowed JavaScript origins</strong> field, enter the redirect URL.</li>
<li>Click the <b>Create</b> button.</li>
<li></li>
<li><img loading="lazy" decoding="async" class="alignnone wp-image-344 " src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted.png" width="662" height="327" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted.png 1085w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-300x148.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1024x505.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-768x379.png 768w" sizes="auto, (max-width: 662px) 100vw, 662px" /></li>
</ul>
</li>
</ul>
<p>A dialog box will appear with OAuth client details, note the <b>Client ID</b> and <b>Client secret</b>. This Client ID and Client secret allow you to access the Google APIs.</p>
<h3 id="google-login-using-javascript">Google Login using JavaScript and PHP</h3>
<p>In this, you can show the Google Sign-in option on home and login, so that the user can easily log in, he does not need to visit the login section.</p>
<p><img loading="lazy" decoding="async" class="wp-image-940 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/01/image-5.png" alt="" width="578" height="343" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-5.png 578w, https://codinghelp.in/wp-content/uploads/2024/01/image-5-300x178.png 300w" sizes="auto, (max-width: 578px) 100vw, 578px" /></p>
<p>Google provides in-depth documentation for the JavaScript API. With the help of these resources, we are going to build a Google login with JavaScript. It basically put a login button on your web page and provides different methods to handle the login journey of a user.</p>
<h4>Step 1:- Create <span style="color: #3366ff;">login.php</span> file name</h4>
<p>Create that file where you want to display Pop up Sign-in Option on visit.</p>
<p>In order to build this flow, Create a <strong>login.php</strong> file and add the code below to it.</p>
<pre class="wp-block-code language-js" style="box-sizing: border-box; border: 0px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; font-size: 13px; font-style: normal; font-weight: 400; margin: 0.5em 0px; outline: 0px; padding: 1em; vertical-align: baseline; overflow: auto; background: #272822; line-height: 1.5; max-width: 100%; color: #f8f8f2; tab-size: 4; word-break: normal; hyphens: none; position: relative; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; text-align: left; white-space: pre; word-spacing: 0px; overflow-wrap: normal; border-radius: 0.3em; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" tabindex="0"><code class="language-js" style="box-sizing: inherit; border: 0px; font-family: monospace, Monaco, Courier; font-size: 1.1em; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 15px; vertical-align: baseline; display: block; overflow-wrap: normal; white-space: pre; background: none; color: #f8f8f2; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; text-align: left; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 4; hyphens: none; overflow: auto;">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Integrating Popup Login with Google One Tap API&lt;/title&gt;
    &lt;!-- Include Google One Tap library --&gt;
&lt;script src="https://accounts.google.com/gsi/client" async defer&gt;&lt;/script&gt;
&lt;script src="https://code.jquery.com/jquery-3.6.4.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="result"&gt;&lt;/div&gt;
&lt;!-- Script to trigger Google One Tap popup login --&gt;
&lt;script&gt;
    function showGoogleOneTap() {
        google.accounts.id.initialize({
            client_id: '1011158678733-ak107l73r5qvc45648bgfpt5e68lkk47.apps.googleusercontent.com', // Replace with your Google API Client ID
            callback: handleCredentialResponse
        });

        google.accounts.id.prompt(notification =&gt; {
            console.log(notification);
        }, credential =&gt; {
            handleCredentialResponse(credential);
        });
    }

    function handleCredentialResponse(response) {
        $.ajax({
                type: 'POST',
                url: 'popupdata.php',
                data: 'credential='+response.credential,
                success: function (response) {
                var jsonget = JSON.parse(response);    
                    // Update the result div with the server response
                    $('#result').html(response);
         if(jsonget.status == "success"){
          window.location.href="https://example.com/dashboard";
        }else if(jsonget.status == "notregister"){
          window.location.href="https://example.com/register";
        }
                },
                error: function () {
                    // Handle errors if the request fails
                    console.error('Request failed');
                }
            });        
    }
&lt;/script&gt;
&lt;script&gt;
    // ... Existing code for showGoogleOneTap() and handleCredentialResponse() ...

    // Automatically show the popup when the page loads
    window.onload = function() {
        showGoogleOneTap();
    };
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>&nbsp;</p>
<h4>Step 2:- Create <span style="color: #3366ff;">popupdata.php</span> file name</h4>
<p>Now that file has to be created, when the visitor logs in his Gmail, Google passes it, then to take action in the backend, a file has to be created which decides what to do with the data received from Google after Google sign-in. To do</p>
<p>Include Your SQL Connection file path, change sql query,</p>
<p>Copy Code for popupdata.php file</p>
<p>In order to build this flow, Create a <strong>popupdata.php</strong> file and add the code below to it.</p>
<pre class="wp-block-code language-js" style="box-sizing: border-box; border: 0px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; font-size: 13px; font-style: normal; font-weight: 400; margin: 0.5em 0px; outline: 0px; padding: 1em; vertical-align: baseline; overflow: auto; background: #272822; line-height: 1.5; max-width: 100%; color: #f8f8f2; tab-size: 4; word-break: normal; hyphens: none; position: relative; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; text-align: left; white-space: pre; word-spacing: 0px; overflow-wrap: normal; border-radius: 0.3em; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" tabindex="0"><code class="language-js" style="box-sizing: inherit; border: 0px; font-family: monospace, Monaco, Courier; font-size: 1.1em; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 15px; vertical-align: baseline; display: block; overflow-wrap: normal; white-space: pre; background: none; color: #f8f8f2; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; text-align: left; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 4; hyphens: none; overflow: auto;">&lt;?php
session_start();
date_default_timezone_set('asia/kolkata');
$date = date('d-m-Y h:i:s A',time());
include('../conn.php');

function getBrowser() { 
  $u_agent = $_SERVER['HTTP_USER_AGENT'];
  $bname = 'Unknown';
  $platform = 'Unknown';
  $version= "";

  //First get the platform?
  if (preg_match('/linux/i', $u_agent)) {
    $platform = 'linux';
  }elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
    $platform = 'mac';
  }elseif (preg_match('/windows|win32/i', $u_agent)) {
    $platform = 'windows';
  }

  // Next get the name of the useragent yes seperately and for good reason
  if(preg_match('/MSIE/i',$u_agent) &amp;&amp; !preg_match('/Opera/i',$u_agent)){
    $bname = 'Internet Explorer';
    $ub = "MSIE";
  }elseif(preg_match('/Firefox/i',$u_agent)){
    $bname = 'Mozilla Firefox';
    $ub = "Firefox";
  }elseif(preg_match('/OPR/i',$u_agent)){
    $bname = 'Opera';
    $ub = "Opera";
  }elseif(preg_match('/Chrome/i',$u_agent) &amp;&amp; !preg_match('/Edge/i',$u_agent)){
    $bname = 'Google Chrome';
    $ub = "Chrome";
  }elseif(preg_match('/Safari/i',$u_agent) &amp;&amp; !preg_match('/Edge/i',$u_agent)){
    $bname = 'Apple Safari';
    $ub = "Safari";
  }elseif(preg_match('/Netscape/i',$u_agent)){
    $bname = 'Netscape';
    $ub = "Netscape";
  }elseif(preg_match('/Edge/i',$u_agent)){
    $bname = 'Edge';
    $ub = "Edge";
  }elseif(preg_match('/Trident/i',$u_agent)){
    $bname = 'Internet Explorer';
    $ub = "MSIE";
  }

  // finally get the correct version number
  $known = array('Version', $ub, 'other');
  $pattern = '#(?&lt;browser&gt;' . join('|', $known) .
')[/ ]+(?&lt;version&gt;[0-9.|a-zA-Z.]*)#';
  if (!preg_match_all($pattern, $u_agent, $matches)) {
    // we have no matching number just continue
  }
  // see how many we have
  $i = count($matches['browser']);
  if ($i != 1) {
    //we will have two since we are not using 'other' argument yet
    //see if version is before or after the name
    if (strripos($u_agent,"Version") &lt; strripos($u_agent,$ub)){
        $version= $matches['version'][0];
    }else {
        $version= $matches['version'][1];
    }
  }else {
    $version= $matches['version'][0];
  }

  // check if we have a number
  if ($version==null || $version=="") {$version="?";}

  return array(
    'userAgent' =&gt; $u_agent,
    'name'      =&gt; $bname,
    'version'   =&gt; $version,
    'platform'  =&gt; $platform,
    'pattern'    =&gt; $pattern
  );
} 

// now try it
$ua=getBrowser();

$browser = $ua['name'];
$version = $ua['version'];
$platform = $ua['platform'];

if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
     $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
     $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}
?&gt;
    &lt;?php
$weburl = "https://meraip.dhboss.com?ip=$ip";
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL =&gt; $weburl,
  CURLOPT_RETURNTRANSFER =&gt; true,
  CURLOPT_ENCODING =&gt; '',
  CURLOPT_MAXREDIRS =&gt; 10,
  CURLOPT_TIMEOUT =&gt; 0,
  CURLOPT_FOLLOWLOCATION =&gt; true,
  CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST =&gt; 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
   $response;
$json = json_decode($response, true);

$city = $json['city'];
$state = $json['region'];
$postal_code = $json['postalcode'];
$org = $json['org'];

<a href="https://codinghelp.in/wp-content/uploads/2024/01/popupsigninlibrary.zip"><span style="color: #3366ff;">require_once('popupsigninlibrary/autoload.php');
</span></a>
$client_id = "1011158678733-ak107l73r5qvc45648bgfpt5e68lkk47.apps.googleusercontent.com";
$id_token = $_POST['credential'];
$client = new Google_Client(['client_id' =&gt; $client_id]);
$responsePayload = $client-&gt;verifyIdToken($id_token); // verify JWT token received
if(!empty($responsePayload)){ 
    // The user's profile info 
        $oauth_provider = 'google'; 
        $_SESSION['access_token'] =  $responsePayload['sub']; 
        $_SESSION['user_first_name'] = $responsePayload['given_name']; 
        $full_name = $responsePayload['name']; 
        $_SESSION['user_last_name']  = $responsePayload['family_name']; 
        $_SESSION['user_email_address']      = $responsePayload['email']; 
        $_SESSION['user_image']    = $responsePayload['picture']; 
        $_SESSION['verifiedEmail']  = $responsePayload['email_verified']; 
        $_SESSION['login_button'] =false;
        
                  // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {
      
      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);

  }

}


if(isset($_SESSION['login_button'])){
   
    $login_button=$_SESSION['login_button'];
  // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {

      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);


$usrdata = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM `loginusers` WHERE `email_id` = '{$_SESSION['user_email_address']}' LIMIT 1"));


$usrrsql = $conn-&gt;prepare("select count(*) from loginusers WHERE email_id = ?");
$usrrsql-&gt;execute([$_SESSION['user_email_address']]);
 $login_key =  md5(microtime().$_SERVER['REMOTE_ADDR']);

$_SESSION['login_key'] = $login_key;
$_SESSION['username'] = $usrdata['username'];


if($usrdata['status']=='approved'||$usrdata['status']=='paywait'){
  $qruirys = "UPDATE `loginusers` SET `login_key` = '$login_key' WHERE `loginusers`.`email_id` = '".$_SESSION['user_email_address']."';";
    $results = mysqli_query($econn, $qruirys);

  $ipquery = "INSERT INTO `ipdetails` (`city`, `subdivision`, `postal_code`, `sim_name`, `ip_address`, `browser_name`, `version_code`, `platform`, `lastlogindate`, `userid`) VALUES ('$city', '$state', '$postal_code', '$org', '$ip', '$browser', '$version', '$platform', '$date', '".$_SESSION['user_email_address']."');";
 $ipcheck = mysqli_query($econn,$ipquery);


echo '{"status":"success"}';

}



  } else {
    session_destroy(); 
     echo '{"status":"notregister"}';
  }
}else{
     $login_button = true;
     
     
}</code></pre>
<p>In this code you include the path of your sql connection file, change the available tables on your database with select sql and also with update sql, make other necessary changes.</p>
<p><code class="language-js" style="box-sizing: inherit; border: 0px; font-family: monospace, Monaco, Courier; font-size: 1.1em; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 15px; vertical-align: baseline; display: block; overflow-wrap: normal; white-space: pre; background: none; color: #f8f8f2; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; text-align: left; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 4; hyphens: none; overflow: auto;"><span style="color: #3366ff;">require_once('popupsigninlibrary/autoload.php'); Download link <span style="color: #ff0000;"><strong><a style="color: #ff0000;" title="Google Sign in library zip file download" href="https://codinghelp.in/wp-content/uploads/2024/01/popupsigninlibrary.zip">Click Here</a><br />
</strong></span></span></code></p><p>The post <a href="https://codinghelp.in/login-with-google-using-javascript-and-php-pop-up/">Login with Google using JavaScript and PHP Pop Up</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/login-with-google-using-javascript-and-php-pop-up/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to create the “login with Google” pop up window? php integration</title>
		<link>https://codinghelp.in/how-to-create-the-login-with-google-pop-up-window-php-integration/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-the-login-with-google-pop-up-window-php-integration</link>
					<comments>https://codinghelp.in/how-to-create-the-login-with-google-pop-up-window-php-integration/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Tue, 23 Jan 2024 15:40:38 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=929</guid>

					<description><![CDATA[<p>Google sign in pop up for website integration php. In the past, I have written an article on Google Login integration with PHP. Following that article, when a user clicks on the login button they will redirect to Google’s website for login, and after completing the authentication they’ll redirect back to your website. During the [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/how-to-create-the-login-with-google-pop-up-window-php-integration/">How to create the “login with Google” pop up window? php integration</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Google sign in pop up for website integration php.</p>
<p>In the past, I have written an article on Google Login integration with PHP. Following that article, when a user clicks on the login button they will redirect to Google’s website for login, and after completing the authentication they’ll redirect back to your website. During the login process, your users are away from your website for a while until they complete the Google authentication.</p>
<p>&nbsp;</p>
<p>If you don’t want to redirect users to the Google login page then another option is to show the Google login popup within your application. The user will enter their credentials in the modal window and on successful authentication, log in to your system. It adds a better user experience to your login flow as everything happens in the modal window without leaving your website.<span id="ezoic-pub-ad-placeholder-106"></span><span id="div-gpt-ad-artisansweb_net-medrectangle-3-0"><br />
<!--EndFragment--> </span></p>
<p>Integrating Popup Login into Your Website with Google One Tap API</p>
<p>Login with Google Account using JavaScript</p>
<p>Popup login is a user-friendly way to provide login functionality on your website without the need for multiple pages or complex forms. In this tutorial, we will explore how to integrate Google&#8217;s One Tap API to implement popup login on your website. We will break down the process into simple steps, allowing readers to easily understand and implement the solution. Additionally, we will add a code snippet to automatically trigger the popup on your website.</p>
<h2>Create Database Table</h2>
<p>A table is required in the database to store the user account information from Google. The following SQL creates a users table in the MySQL database to hold the Google profile information.</p>
<pre style="box-sizing: border-box; margin: 0px 0px 1rem; padding: 10px; border: 1px solid #e6e7e9; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; font-family: var(--bs-font-monospace); font-size: 15px; display: block; overflow: auto; background: #f4f5f7; word-break: break-all; overflow-wrap: break-word; white-space: pre-wrap; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; color: #000000;"><span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">CREATE</span> <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">TABLE</span> <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`users`</span> (
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`id`</span> <span class="hljs-built_in" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #0086b3;">int</span>(<span class="hljs-number" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #40a070;">11</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span> AUTO_INCREMENT,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`oauth_provider`</span> enum(<span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">'google'</span>,<span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">'facebook'</span>,<span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">'twitter'</span>,<span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">'linkedin'</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span> <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">DEFAULT</span> <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">'google'</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`oauth_uid`</span> <span class="hljs-built_in" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #0086b3;">varchar</span>(<span class="hljs-number" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #40a070;">50</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`first_name`</span> <span class="hljs-built_in" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #0086b3;">varchar</span>(<span class="hljs-number" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #40a070;">25</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`last_name`</span> <span class="hljs-built_in" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #0086b3;">varchar</span>(<span class="hljs-number" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #40a070;">25</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`email`</span> <span class="hljs-built_in" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #0086b3;">varchar</span>(<span class="hljs-number" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #40a070;">50</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`picture`</span> <span class="hljs-built_in" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #0086b3;">varchar</span>(<span class="hljs-number" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #40a070;">255</span>) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">DEFAULT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`created`</span> datetime <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  <span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`modified`</span> datetime <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NOT</span> <span class="hljs-literal" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">NULL</span>,
  PRIMARY <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">KEY</span> (<span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #219161;">`id`</span>)
) <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">ENGINE</span>=<span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">InnoDB</span> <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">DEFAULT</span> <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">CHARSET</span>=utf8 <span class="hljs-keyword" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #954121;">COLLATE</span>=utf8_unicode_ci;</pre>
<h2>Google Sign In with HTML API and JavaScript (index.html)</h2>
<p>Since the example code uses HTML API, only one page (index.php) is required to add the Sign In With Google button and process Google account authentication without page refresh using JavaScript.</p>
<p>Load Google Client Library:<br />
Include the Google Identity API Client library.</p>
<pre style="box-sizing: border-box; margin: 0px 0px 1rem; padding: 10px; border: 1px solid #e6e7e9; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; font-family: var(--bs-font-monospace); font-size: 15px; display: block; overflow: auto; background: #f4f5f7; word-break: break-all; overflow-wrap: break-word; white-space: pre-wrap; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; color: #5f5e4e;"><span class="hljs-tag" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #ba6236;">&lt;<span class="hljs-name" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #ba6236;">script</span> <span class="hljs-attr" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important;">src</span>=<span class="hljs-string" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #7d9726;">"https://accounts.google.com/gsi/client"</span> <span class="hljs-attr" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important;">async</span>&gt;</span><span class="hljs-tag" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #ba6236;">&lt;/<span class="hljs-name" style="box-sizing: border-box; margin: 0px; padding: 0px; border: none; -webkit-font-smoothing: antialiased; box-shadow: none; outline: none !important; color: #ba6236;">script</span>&gt;</span></pre>
<h2>Sign In With Google HTML API using JavaScript</h2>
<p>The following functionality will be implemented to integrate the Google Login feature into the website using Google Identity API.</p>
<ul>
<li>Create an HTML element to render the Sign In With Google button.</li>
<li>Attach Google OAuth dialog to button using Google HTML API.</li>
<li>Post ID token to the server-side credential response handler script using JavaScript.</li>
<li>Decode JWT token and retrieve user’s account information using PHP.</li>
<li>Insert account data in the database using PHP and MySQL.</li>
<li>Display Google account details on the web page without page refresh.</li>
</ul>
<h1><span style="font-size: 14pt;">How to get client id and secret key with </span><span style="font-size: 14pt;">Could Console </span><span style="font-size: 14pt;">&#8211; console.cloud.google.com</span></h1>
<ul class="step_list">
<li>Go to the <a href="https://console.cloud.google.com/welcome?hl=fr" target="_blank" rel="noopener noreferrer">Google API Console</a>.</li>
<li>Select an existing project from the projects list, or click <b>NEW PROJECT</b> to create a new project:
<ul class="bullet_disk_list">
<li>Enter the <b>Project Name</b>. (You can enter the name of your website)</li>
<li><img loading="lazy" decoding="async" class="alignnone wp-image-345" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1.png" alt="" width="536" height="320" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1.png 1079w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-300x179.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-1024x611.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-768x458.png 768w" sizes="auto, (max-width: 536px) 100vw, 536px" /></li>
<li>Under the Project Name, you will see the Google API console automatically creates a project ID. Optionally you can change this project ID by the <b>Edit</b> link. But project ID must be unique worldwide.</li>
<li>Click on the <b>CREATE</b> button and the project will be created in some seconds.</li>
</ul>
</li>
<li>In the left side navigation panel, select <b>Credentials</b> under the <b>APIs &amp; Services</b> section.</li>
<li>Select the <b>OAuth consent screen</b> tab, specify the consent screen settings.
<ul class="bullet_disk_list">
<li>In <b>Application name</b> field, enter the name of your Application.</li>
<li>In <b>Support email</b> filed, choose an email address for user support.</li>
<li>In the <b>Authorized domains</b>, specify the domains which will be allowed to authenticate using OAuth.</li>
<li>Click the <b>Save</b> button.
<ul>
<li><img loading="lazy" decoding="async" class="alignnone size-full wp-image-346" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2.png" alt="" width="909" height="614" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2.png 909w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2-300x203.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2-768x519.png 768w" sizes="auto, (max-width: 909px) 100vw, 909px" /></li>
<li>Click On Publish App button (If you do not publish this, your visitor cannot log in, please remember this and publish it.)</li>
</ul>
</li>
</ul>
</li>
<li>Select the <b>Credentials</b> tab, click the <b>Create credentials</b> drop-down and select <b>OAuth client ID</b>.
<ul class="bullet_disk_list">
<li><img loading="lazy" decoding="async" class="alignnone size-full wp-image-347" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3.png" alt="" width="1059" height="514" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3.png 1059w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-300x146.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-1024x497.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-768x373.png 768w" sizes="auto, (max-width: 1059px) 100vw, 1059px" /></li>
<li>In the <b>Application type</b> section, select <b>Web application</b>.</li>
<li>in the <strong>Name</strong> Enter Your Project Name</li>
<li><img loading="lazy" decoding="async" class="wp-image-924 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/01/image-1.png" alt="" width="640" height="371" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-1.png 1107w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-300x174.png 300w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-1024x594.png 1024w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-768x445.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>In the <strong>Allowed JavaScript origins</strong> field, enter the redirect URL.</li>
<li>Click the <b>Create</b> button.</li>
<li></li>
<li><img loading="lazy" decoding="async" class="alignnone wp-image-344 " src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted.png" width="662" height="327" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted.png 1085w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-300x148.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1024x505.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-768x379.png 768w" sizes="auto, (max-width: 662px) 100vw, 662px" /></li>
</ul>
</li>
</ul>
<p>A dialog box will appear with OAuth client details, note the <b>Client ID</b> and <b>Client secret</b>. This Client ID and Client secret allow you to access the Google APIs.</p>
<h2>Google Login PopUp in php source code</h2>
<p>In this, you can show the Google Sign-in option on home and login, so that the user can easily log in, he does not need to visit the login section.</p>
<p><img loading="lazy" decoding="async" class="wp-image-933 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/01/image-4.png" alt="" width="694" height="323" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-4.png 694w, https://codinghelp.in/wp-content/uploads/2024/01/image-4-300x140.png 300w" sizes="auto, (max-width: 694px) 100vw, 694px" /></p>
<h3>Method &#8211; Google Sign-in  pop up</h3>
<h4>Step 1:- Create <span style="color: #3366ff;">index.php</span> file name</h4>
<p>Create that file where you want to display Pop up Sign-in Option on visit.</p>
<p>Change This Code in &#8220;<strong>data</strong>&#8211;<strong>client_id</strong>&#8221;</p>
<p>Copy Code for index.php file</p>
<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Integrating Popup Login with Google One Tap API&lt;/title&gt;
    &lt;!-- Include Google One Tap library --&gt;
&lt;script src="https://accounts.google.com/gsi/client" async defer&gt;&lt;/script&gt;
&lt;script src="https://code.jquery.com/jquery-3.6.4.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="result"&gt;&lt;/div&gt;
&lt;!-- Script to trigger Google One Tap popup login --&gt;
&lt;script&gt;
    function showGoogleOneTap() {
        google.accounts.id.initialize({
            client_id: '1011158678733-ak107l73r5qvc45648bgfpt5e68lkk47.apps.googleusercontent.com', // Replace with your Google API Client ID
            callback: handleCredentialResponse
        });

        google.accounts.id.prompt(notification =&gt; {
            console.log(notification);
        }, credential =&gt; {
            handleCredentialResponse(credential);
        });
    }

    function handleCredentialResponse(response) {
        //var jsondata = JSON.parse(response);
        console.log(response);
        var jsonData = {
        request_type: 'user_auth',
        credential: response.credential
    };
        $.ajax({
                type: 'POST',
                url: 'popupdata.php', // Replace with your server endpoint URL
                contentType: 'application/json', // Set content type to JSON
                data: JSON.stringify(jsonData), // Convert JSON data to string
                success: function (response) {
                var jsonget = JSON.parse(response);    
                    // Update the result div with the server response
                    $('#result').html(response);
         if(jsonget.status == "success"){
          window.location.href="https://example.com/dashboard";
        }else if(jsonget.status == "notregister"){
          window.location.href="https://example.com/register";
        }
                },
                error: function () {
                    // Handle errors if the request fails
                    console.error('Request failed');
                }
            });        
    }
&lt;/script&gt;
&lt;script&gt;
    // ... Existing code for showGoogleOneTap() and handleCredentialResponse() ...

    // Automatically show the popup when the page loads
    window.onload = function() {
        showGoogleOneTap();
    };
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<h4>Step 2:- Create <span style="color: #3366ff;">popupdata.php</span> file name</h4>
<p>Now that file has to be created, when the visitor logs in his Gmail, Google passes it, then to take action in the backend, a file has to be created which decides what to do with the data received from Google after Google sign-in. To do</p>
<p>Include Your SQL Connection file path, change sql query,</p>
<p>Copy Code for popupdata.php file</p>
<pre><code>&lt;?php
session_start();
date_default_timezone_set('asia/kolkata');
$date = date('d-m-Y h:i:s A',time());
include('../conn.php');
 
// Retrieve JSON from POST body 
$jsonStr = file_get_contents('php://input'); 
$jsonObj = json_decode($jsonStr); 
 
if(!empty($jsonObj-&gt;request_type) &amp;&amp; $jsonObj-&gt;request_type == 'user_auth'){ 
    $credential = !empty($jsonObj-&gt;credential)?$jsonObj-&gt;credential:''; 
 
    // Decode response payload from JWT token 
    list($header, $payload, $signature) = explode (".", $credential); 
    $responsePayload = json_decode(base64_decode($payload)); 
 
    if(!empty($responsePayload)){ 
        // The user's profile info 
        $oauth_provider = 'google'; 
        $_SESSION['access_token'] =  $oauth_uid  = !empty($responsePayload-&gt;sub)?$responsePayload-&gt;sub:''; 
        $_SESSION['user_first_name'] = !empty($responsePayload-&gt;given_name)?$responsePayload-&gt;given_name:''; 
        $full_name = !empty($responsePayload-&gt;name)?$responsePayload-&gt;name:''; 
        $_SESSION['user_last_name']  = !empty($responsePayload-&gt;family_name)?$responsePayload-&gt;family_name:''; 
        $_SESSION['user_email_address']      = !empty($responsePayload-&gt;email)?$responsePayload-&gt;email:''; 
        $_SESSION['user_image']    = !empty($responsePayload-&gt;picture)?$responsePayload-&gt;picture:''; 
        $_SESSION['verifiedEmail']  = !empty($responsePayload-&gt;email_verified)?$responsePayload-&gt;email_verified:''; 
        $_SESSION['login_button'] =false;
        
          // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {
      
      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);

  }
         
    }
} 


if(isset($_SESSION['login_button'])){
   
    $login_button=$_SESSION['login_button'];
  // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {

      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);


$usrdata = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM `loginusers` WHERE `email_id` = '{$_SESSION['user_email_address']}' LIMIT 1"));
$usrrsql = $conn-&gt;prepare("select count(*) from loginusers WHERE email_id = ?");
$usrrsql-&gt;execute([$_SESSION['user_email_address']]);
 $login_key =  md5(microtime().$_SERVER['REMOTE_ADDR']);
$_SESSION['login_key'] = $login_key;
$_SESSION['username'] = $usrdata['username'];

if($usrdata['status']=='approved'||$usrdata['status']=='paywait'){
  $qruirys = "UPDATE `loginusers` SET `login_key` = '$login_key' WHERE `loginusers`.`email_id` = '".$_SESSION['user_email_address']."';";
    $results = mysqli_query($econn, $qruirys);
echo '{"status":"success"}';

}
  } else {
    session_destroy(); 
     echo '{"status":"notregister"}';
  }
}else{
     $login_button = true;
     
     
}
?&gt;
</code></pre>
<p>In this code you include the path of your sql connection file, change the available tables on your database with select sql and also with update sql, make other necessary changes.</p><p>The post <a href="https://codinghelp.in/how-to-create-the-login-with-google-pop-up-window-php-integration/">How to create the “login with Google” pop up window? php integration</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/how-to-create-the-login-with-google-pop-up-window-php-integration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Integrate Google Popup Sign in into Website &#124;&#124; Google sign in pop up for website integration php</title>
		<link>https://codinghelp.in/integrate-google-popup-sign-in-into-website-google-sign-in-pop-up-for-website-integration-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=integrate-google-popup-sign-in-into-website-google-sign-in-pop-up-for-website-integration-php</link>
					<comments>https://codinghelp.in/integrate-google-popup-sign-in-into-website-google-sign-in-pop-up-for-website-integration-php/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Tue, 23 Jan 2024 15:09:42 +0000</pubDate>
				<category><![CDATA[HTML TUTORIAL]]></category>
		<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=922</guid>

					<description><![CDATA[<p>Gmail / Google Sign in Popup Website &#124;&#124; Google sign in pop up for website integration php. Integrating Popup Login into Your Website with Google One Tap API Login with Google Account using JavaScript Popup login is a user-friendly way to provide login functionality on your website without the need for multiple pages or complex [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/integrate-google-popup-sign-in-into-website-google-sign-in-pop-up-for-website-integration-php/">Integrate Google Popup Sign in into Website || Google sign in pop up for website integration php</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Gmail / Google Sign in Popup Website || Google sign in pop up for website integration php.</p>
<p>Integrating Popup Login into Your Website with Google One Tap API</p>
<p>Login with Google Account using JavaScript</p>
<p>Popup login is a user-friendly way to provide login functionality on your website without the need for multiple pages or complex forms. In this tutorial, we will explore how to integrate Google&#8217;s One Tap API to implement popup login on your website. We will break down the process into simple steps, allowing readers to easily understand and implement the solution. Additionally, we will add a code snippet to automatically trigger the popup on your website.</p>
<h2>Sign In With Google HTML API using JavaScript</h2>
<p>The following functionality will be implemented to integrate the Google Login feature into the website using Google Identity API.</p>
<ul>
<li>Create an HTML element to render the Sign In With Google button.</li>
<li>Attach Google OAuth dialog to button using Google HTML API.</li>
<li>Post ID token to the server-side credential response handler script using JavaScript.</li>
<li>Decode JWT token and retrieve user’s account information using PHP.</li>
<li>Insert account data in the database using PHP and MySQL.</li>
<li>Display Google account details on the web page without page refresh.</li>
</ul>
<h1><span style="font-size: 14pt;">Create Google Pop up sign in API Could Console Project &#8211; console.cloud.google.com</span></h1>
<ul class="step_list">
<li>Go to the <a href="https://console.cloud.google.com/welcome?hl=fr" target="_blank" rel="noopener noreferrer">Google API Console</a>.</li>
<li>Select an existing project from the projects list, or click <b>NEW PROJECT</b> to create a new project:
<ul class="bullet_disk_list">
<li>Enter the <b>Project Name</b>. (You can enter the name of your website)</li>
<li><img loading="lazy" decoding="async" class="alignnone wp-image-345" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1.png" alt="" width="536" height="320" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1.png 1079w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-300x179.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-1024x611.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1-768x458.png 768w" sizes="auto, (max-width: 536px) 100vw, 536px" /></li>
<li>Under the Project Name, you will see the Google API console automatically creates a project ID. Optionally you can change this project ID by the <b>Edit</b> link. But project ID must be unique worldwide.</li>
<li>Click on the <b>CREATE</b> button and the project will be created in some seconds.</li>
</ul>
</li>
<li>In the left side navigation panel, select <b>Credentials</b> under the <b>APIs &amp; Services</b> section.</li>
<li>Select the <b>OAuth consent screen</b> tab, specify the consent screen settings.
<ul class="bullet_disk_list">
<li>In <b>Application name</b> field, enter the name of your Application.</li>
<li>In <b>Support email</b> filed, choose an email address for user support.</li>
<li>In the <b>Authorized domains</b>, specify the domains which will be allowed to authenticate using OAuth.</li>
<li>Click the <b>Save</b> button.
<ul>
<li><img loading="lazy" decoding="async" class="alignnone size-full wp-image-346" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2.png" alt="" width="909" height="614" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2.png 909w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2-300x203.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-2-768x519.png 768w" sizes="auto, (max-width: 909px) 100vw, 909px" /></li>
<li>Click On Publish App button (If you do not publish this, your visitor cannot log in, please remember this and publish it.)</li>
</ul>
</li>
</ul>
</li>
<li>Select the <b>Credentials</b> tab, click the <b>Create credentials</b> drop-down and select <b>OAuth client ID</b>.
<ul class="bullet_disk_list">
<li><img loading="lazy" decoding="async" class="alignnone size-full wp-image-347" src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3.png" alt="" width="1059" height="514" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3.png 1059w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-300x146.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-1024x497.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-3-768x373.png 768w" sizes="auto, (max-width: 1059px) 100vw, 1059px" /></li>
<li>In the <b>Application type</b> section, select <b>Web application</b>.</li>
<li>in the <strong>Name</strong> Enter Your Project Name</li>
<li><img loading="lazy" decoding="async" class="wp-image-924 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/01/image-1.png" alt="" width="640" height="371" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-1.png 1107w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-300x174.png 300w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-1024x594.png 1024w, https://codinghelp.in/wp-content/uploads/2024/01/image-1-768x445.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></li>
<li>In the <strong>Allowed JavaScript origins</strong> field, enter the redirect URL.</li>
<li>Click the <b>Create</b> button.</li>
<li></li>
<li><img loading="lazy" decoding="async" class="alignnone wp-image-344 " src="https://codinghelp.in/wp-content/uploads/2022/10/Pasted.png" width="662" height="327" srcset="https://codinghelp.in/wp-content/uploads/2022/10/Pasted.png 1085w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-300x148.png 300w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-1024x505.png 1024w, https://codinghelp.in/wp-content/uploads/2022/10/Pasted-768x379.png 768w" sizes="auto, (max-width: 662px) 100vw, 662px" /></li>
</ul>
</li>
</ul>
<p>A dialog box will appear with OAuth client details, note the <b>Client ID</b> and <b>Client secret</b>. This Client ID and Client secret allow you to access the Google APIs.</p>
<h2>Integrate Google Popup Sign in into Website ?</h2>
<p>We are going to tell you two types of pop-up google sign in script, method 1, method 2, so you must check both, whichever you like, you can put it in your website.</p>
<h3>Method 1- Sign in with pop up</h3>
<ul>
<li>First you will see the icon text &#8220;<strong>Sign in with Google</strong>&#8221; when a visitor comes to your website for the first time. When a visitor comes to your website for the second time, he will not get the option of Sign in with Google.</li>
<li>When your visitor comes to your website again you will get Gmail auto select like in Image 3.</li>
<li>You have to visit the Sign in with Google section and select your email, and you get logged in to the website.</li>
</ul>
<p><img loading="lazy" decoding="async" class="wp-image-927 alignleft" src="https://codinghelp.in/wp-content/uploads/2024/01/image-3.png" alt="google sign in pop up image" width="676" height="557" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-3.png 776w, https://codinghelp.in/wp-content/uploads/2024/01/image-3-300x247.png 300w, https://codinghelp.in/wp-content/uploads/2024/01/image-3-768x632.png 768w" sizes="auto, (max-width: 676px) 100vw, 676px" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4>Step 1:- Create <span style="color: #3366ff;">popup.php</span> file name</h4>
<p>Create that file where you want to display Pop up Sign-in Option on visit.</p>
<p>Change This Code in &#8220;<strong>data</strong>&#8211;<strong>client_id</strong>&#8221;</p>
<p>Copy Code for popup.php file</p>
<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Integrating Popup Login with Google One Tap API&lt;/title&gt;
    &lt;!-- Include Google One Tap library --&gt;
&lt;script src="https://accounts.google.com/gsi/client" async defer&gt;&lt;/script&gt;
&lt;script src="https://code.jquery.com/jquery-3.6.4.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- Sign In With Google button with HTML data attributes API --&gt;
&lt;div id="g_id_onload"
    data-client_id="1011158678733-ak107l73r5qvc45648bgfpt5e68lkk47.apps.googleusercontent.com"
    data-context="signin"
    data-ux_mode="popup"
    data-callback="handleCredentialResponse"
    data-auto_prompt="false"&gt;
&lt;/div&gt;

&lt;div class="g_id_signin"
    data-type="standard"
    data-shape="rectangular"
    data-theme="outline"
    data-text="signin_with"
    data-size="large"
    data-logo_alignment="left"&gt;
&lt;/div&gt;

&lt;!-- Display the user's profile info --&gt;
&lt;div class="pro-data hidden"&gt;&lt;/div&gt;

&lt;script&gt;
// Credential response handler function
function handleCredentialResponse(response){
    // Post JWT token to server-side
    fetch("popupdata.php", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ request_type:'user_auth', credential: response.credential }),
    })
    .then(response =&gt; response.json())
    .then(data =&gt; {
        console.log(data);
        if(data.status == "success"){
          window.location.href="https://example.com/dashboard";
        }else if(data.status == "notregister"){
          window.location.href="https://example.com/register";
        }
        
        if(data.status == 1){
            let responsePayload = data.pdata;

            // Display the user account data
            let profileHTML = '&lt;h3&gt;Welcome '+responsePayload.given_name+'! &lt;a href="javascript:void(0);" onclick="signOut('+responsePayload.sub+');"&gt;Sign out&lt;/a&gt;&lt;/h3&gt;';
     <code>       profileHTML += '&lt;img src="'+responsePayload.picture+'"/&gt;&lt;p&gt;&lt;b&gt;Auth ID: &lt;/b&gt;'+responsePayload.sub+'&lt;/p&gt;&lt;p&gt;&lt;b&gt;Name: &lt;/b&gt;'+responsePayload.name+'&lt;/p&gt;&lt;p&gt;&lt;b&gt;Email: &lt;/b&gt;'+responsePayload.email+'&lt;/p&gt;';
            document.getElementsByClassName("pro-data")[0].innerHTML = profileHTML;
            
            document.querySelector("#btnWrap").classList.add("hidden");
            document.querySelector(".pro-data").classList.remove("hidden");
        }
    })
    .catch(console.error);
}

// Sign out the user
function signOut(authID) {
    document.getElementsByClassName("pro-data")[0].innerHTML = '';
    document.querySelector("#btnWrap").classList.remove("hidden");
    document.querySelector(".pro-data").classList.add("hidden");
}    
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code> In the code that you will copy, you will have to change "<strong>data-client_id</strong>". This client_id would have been obtained from Could Console if you have followed the above steps. </code></pre>
<h4>Step 2:- Create <span style="color: #3366ff;">popupdata.php</span> file name</h4>
<p>Now that file has to be created, when the visitor logs in his Gmail, Google passes it, then to take action in the backend, a file has to be created which decides what to do with the data received from Google after Google sign-in. To do</p>
<p>Include Your SQL Connection file path, change sql query,</p>
<p>Copy Code for popupdata.php file</p>
<pre><code>&lt;?php
session_start();
date_default_timezone_set('asia/kolkata');
$date = date('d-m-Y h:i:s A',time());
include('../conn.php');
 
// Retrieve JSON from POST body 
$jsonStr = file_get_contents('php://input'); 
$jsonObj = json_decode($jsonStr); 
 
if(!empty($jsonObj-&gt;request_type) &amp;&amp; $jsonObj-&gt;request_type == 'user_auth'){ 
    $credential = !empty($jsonObj-&gt;credential)?$jsonObj-&gt;credential:''; 
 
    // Decode response payload from JWT token 
    list($header, $payload, $signature) = explode (".", $credential); 
    $responsePayload = json_decode(base64_decode($payload)); 
 
    if(!empty($responsePayload)){ 
        // The user's profile info 
        $oauth_provider = 'google'; 
        $_SESSION['access_token'] =  $oauth_uid  = !empty($responsePayload-&gt;sub)?$responsePayload-&gt;sub:''; 
        $_SESSION['user_first_name'] = !empty($responsePayload-&gt;given_name)?$responsePayload-&gt;given_name:''; 
        $full_name = !empty($responsePayload-&gt;name)?$responsePayload-&gt;name:''; 
        $_SESSION['user_last_name']  = !empty($responsePayload-&gt;family_name)?$responsePayload-&gt;family_name:''; 
        $_SESSION['user_email_address']      = !empty($responsePayload-&gt;email)?$responsePayload-&gt;email:''; 
        $_SESSION['user_image']    = !empty($responsePayload-&gt;picture)?$responsePayload-&gt;picture:''; 
        $_SESSION['verifiedEmail']  = !empty($responsePayload-&gt;email_verified)?$responsePayload-&gt;email_verified:''; 
        $_SESSION['login_button'] =false;
        
          // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {
      
      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);

  }
         
    }
} 


if(isset($_SESSION['login_button'])){
   
    $login_button=$_SESSION['login_button'];
  // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {

      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);


$usrdata = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM `loginusers` WHERE `email_id` = '{$_SESSION['user_email_address']}' LIMIT 1"));
$usrrsql = $conn-&gt;prepare("select count(*) from loginusers WHERE email_id = ?");
$usrrsql-&gt;execute([$_SESSION['user_email_address']]);
 $login_key =  md5(microtime().$_SERVER['REMOTE_ADDR']);
$_SESSION['login_key'] = $login_key;
$_SESSION['username'] = $usrdata['username'];

if($usrdata['status']=='approved'||$usrdata['status']=='paywait'){
  $qruirys = "UPDATE `loginusers` SET `login_key` = '$login_key' WHERE `loginusers`.`email_id` = '".$_SESSION['user_email_address']."';";
    $results = mysqli_query($econn, $qruirys);
echo '{"status":"success"}';

}
  } else {
    session_destroy(); 
     echo '{"status":"notregister"}';
  }
}else{
     $login_button = true;
     
     
}
?&gt;
</code></pre>
<p>In this code you include the path of your sql connection file, change the available tables on your database with select sql and also with update sql, make other necessary changes.</p>
<h2>Create Database Table</h2>
<p>To store the user account information from Google, a table needs to be created in the database. The following SQL creates a <code>users</code> table with some basic fields in the MySQL database to hold the Google profile information.</p>
<pre><code>CREATE TABLE `users` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `oauth_provider` enum('google','facebook','twitter','linkedin') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'google',
 `oauthtoken` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `first_name` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
 `last_name` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
 `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `verifiedEmail` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
 `locale` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
 `picture` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
 `created` datetime NOT NULL,
 `modified` datetime NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;</code></pre>
<h2>Google sign in pop up for website integration php</h2>
<p>In this, you can show the Google Sign-in option on home and login, so that the user can easily log in, he does not need to visit the login section.</p>
<p><img loading="lazy" decoding="async" class="wp-image-933 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2024/01/image-4.png" alt="" width="694" height="323" srcset="https://codinghelp.in/wp-content/uploads/2024/01/image-4.png 694w, https://codinghelp.in/wp-content/uploads/2024/01/image-4-300x140.png 300w" sizes="auto, (max-width: 694px) 100vw, 694px" /></p>
<h3>Method 2- Google Sign-in  pop up</h3>
<h4>Step 1:- Create <span style="color: #3366ff;">index.php</span> file name</h4>
<p>Create that file where you want to display Pop up Sign-in Option on visit.</p>
<p>Change This Code in &#8220;<strong>data</strong>&#8211;<strong>client_id</strong>&#8221;</p>
<p>Copy Code for index.php file</p>
<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Integrating Popup Login with Google One Tap API&lt;/title&gt;
    &lt;!-- Include Google One Tap library --&gt;
&lt;script src="https://accounts.google.com/gsi/client" async defer&gt;&lt;/script&gt;
&lt;script src="https://code.jquery.com/jquery-3.6.4.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="result"&gt;&lt;/div&gt;
&lt;!-- Script to trigger Google One Tap popup login --&gt;
&lt;script&gt;
    function showGoogleOneTap() {
        google.accounts.id.initialize({
            client_id: '1011158678733-ak107l73r5qvc45648bgfpt5e68lkk47.apps.googleusercontent.com', // Replace with your Google API Client ID
            callback: handleCredentialResponse
        });

        google.accounts.id.prompt(notification =&gt; {
            console.log(notification);
        }, credential =&gt; {
            handleCredentialResponse(credential);
        });
    }

    function handleCredentialResponse(response) {
        //var jsondata = JSON.parse(response);
        console.log(response);
        var jsonData = {
        request_type: 'user_auth',
        credential: response.credential
    };
        $.ajax({
                type: 'POST',
                url: 'popupdata.php', // Replace with your server endpoint URL
                contentType: 'application/json', // Set content type to JSON
                data: JSON.stringify(jsonData), // Convert JSON data to string
                success: function (response) {
                var jsonget = JSON.parse(response);    
                    // Update the result div with the server response
                    $('#result').html(response);
         if(jsonget.status == "success"){
          window.location.href="https://example.com/dashboard";
        }else if(jsonget.status == "notregister"){
          window.location.href="https://example.com/register";
        }
                },
                error: function () {
                    // Handle errors if the request fails
                    console.error('Request failed');
                }
            });        
    }
&lt;/script&gt;
&lt;script&gt;
    // ... Existing code for showGoogleOneTap() and handleCredentialResponse() ...

    // Automatically show the popup when the page loads
    window.onload = function() {
        showGoogleOneTap();
    };
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<h4>Step 2:- Create <span style="color: #3366ff;">popupdata.php</span> file name</h4>
<p>Now that file has to be created, when the visitor logs in his Gmail, Google passes it, then to take action in the backend, a file has to be created which decides what to do with the data received from Google after Google sign-in. To do</p>
<p>Include Your SQL Connection file path, change sql query,</p>
<p>Copy Code for popupdata.php file</p>
<pre><code>&lt;?php
session_start();
date_default_timezone_set('asia/kolkata');
$date = date('d-m-Y h:i:s A',time());
include('../conn.php');
 
// Retrieve JSON from POST body 
$jsonStr = file_get_contents('php://input'); 
$jsonObj = json_decode($jsonStr); 
 
if(!empty($jsonObj-&gt;request_type) &amp;&amp; $jsonObj-&gt;request_type == 'user_auth'){ 
    $credential = !empty($jsonObj-&gt;credential)?$jsonObj-&gt;credential:''; 
 
    // Decode response payload from JWT token 
    list($header, $payload, $signature) = explode (".", $credential); 
    $responsePayload = json_decode(base64_decode($payload)); 
 
    if(!empty($responsePayload)){ 
        // The user's profile info 
        $oauth_provider = 'google'; 
        $_SESSION['access_token'] =  $oauth_uid  = !empty($responsePayload-&gt;sub)?$responsePayload-&gt;sub:''; 
        $_SESSION['user_first_name'] = !empty($responsePayload-&gt;given_name)?$responsePayload-&gt;given_name:''; 
        $full_name = !empty($responsePayload-&gt;name)?$responsePayload-&gt;name:''; 
        $_SESSION['user_last_name']  = !empty($responsePayload-&gt;family_name)?$responsePayload-&gt;family_name:''; 
        $_SESSION['user_email_address']      = !empty($responsePayload-&gt;email)?$responsePayload-&gt;email:''; 
        $_SESSION['user_image']    = !empty($responsePayload-&gt;picture)?$responsePayload-&gt;picture:''; 
        $_SESSION['verifiedEmail']  = !empty($responsePayload-&gt;email_verified)?$responsePayload-&gt;email_verified:''; 
        $_SESSION['login_button'] =false;
        
          // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {
      
      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);

  }
         
    }
} 


if(isset($_SESSION['login_button'])){
   
    $login_button=$_SESSION['login_button'];
  // checking if user is already exists in database
  $sql = "SELECT * FROM loginusers WHERE email_id ='{$_SESSION['user_email_address']}'";
  $results = mysqli_query($conn, $sql);
  if (mysqli_num_rows($results) &gt; 0) {

      $qruiry = "UPDATE `loginusers` SET `oauthtoken` = '{$_SESSION['access_token']}', `verifiedEmail` = '{$_SESSION['verifiedEmail']}' WHERE `loginusers`.`email_id` = '{$_SESSION['user_email_address']}';";
    // user is exists
    $result = mysqli_query($conn, $qruiry);


$usrdata = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM `loginusers` WHERE `email_id` = '{$_SESSION['user_email_address']}' LIMIT 1"));
$usrrsql = $conn-&gt;prepare("select count(*) from loginusers WHERE email_id = ?");
$usrrsql-&gt;execute([$_SESSION['user_email_address']]);
 $login_key =  md5(microtime().$_SERVER['REMOTE_ADDR']);
$_SESSION['login_key'] = $login_key;
$_SESSION['username'] = $usrdata['username'];

if($usrdata['status']=='approved'||$usrdata['status']=='paywait'){
  $qruirys = "UPDATE `loginusers` SET `login_key` = '$login_key' WHERE `loginusers`.`email_id` = '".$_SESSION['user_email_address']."';";
    $results = mysqli_query($econn, $qruirys);
echo '{"status":"success"}';

}
  } else {
    session_destroy(); 
     echo '{"status":"notregister"}';
  }
}else{
     $login_button = true;
     
     
}
?&gt;
</code></pre>
<p>In this code you include the path of your sql connection file, change the available tables on your database with select sql and also with update sql, make other necessary changes.</p>
<pre></pre><p>The post <a href="https://codinghelp.in/integrate-google-popup-sign-in-into-website-google-sign-in-pop-up-for-website-integration-php/">Integrate Google Popup Sign in into Website || Google sign in pop up for website integration php</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/integrate-google-popup-sign-in-into-website-google-sign-in-pop-up-for-website-integration-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ip address block after limit cross php</title>
		<link>https://codinghelp.in/ip-address-block-after-limit-cross-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ip-address-block-after-limit-cross-php</link>
					<comments>https://codinghelp.in/ip-address-block-after-limit-cross-php/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Sun, 24 Dec 2023 13:27:06 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=912</guid>

					<description><![CDATA[<p>ip address block after limit cross php If you want to implement IP address blocking after a certain limit is crossed, you can use PHP along with some form of persistent storage to keep track of the number of requests from each IP address. Here&#8217;s a simple example using a file to store the request [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/ip-address-block-after-limit-cross-php/">ip address block after limit cross php</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1>ip address block after limit cross php</h1>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 0px 0px 1.25em; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">If you want to implement IP address blocking after a certain limit is crossed, you can use PHP along with some form of persistent storage to keep track of the number of requests from each IP address. Here&#8217;s a simple example using a file to store the request count for each IP:</p>
<div class="bg-black rounded-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; border-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(0,0,0,var(--tw-bg-opacity));">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; position: relative; display: flex; align-items: center; justify-content: space-between; border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(52,53,65,var(--tw-bg-opacity)); padding: 0.5rem 1rem; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 0.75rem; line-height: 1rem; --tw-text-opacity: 1; color: rgba(217,217,227,var(--tw-text-opacity));"><span style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">php</span><button class="flex gap-1 items-center" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: inherit; font-family: inherit; font-size: 12px; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-transform: none; appearance: button; background-color: transparent; background-image: none; cursor: pointer; display: flex; align-items: center; gap: 0.25rem;">Copy code</button></div>
<div class="p-4 overflow-y-auto" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; overflow-y: auto; padding: 1rem;">
<p><code class="!whitespace-pre hljs language-php" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: inherit; font-size: inherit; color: #ffffff; font-weight: inherit; background: none; border-radius: 0.3em; line-height: 1.5; padding: 0.1em; white-space: normal; overflow-wrap: normal; hyphens: none; tab-size: 4; text-align: left; word-break: normal; word-spacing: normal;"><span class="hljs-meta" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.6);">&lt;?php</span></code></p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Function to get the client&#8217;s IP address</span><br />
<span class="hljs-function" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;"><span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">function</span> <span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">getClientIP</span>() </span>{<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8221;</span>;<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span> (<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_CLIENT_IP&#8217;</span>]))<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_CLIENT_IP&#8217;</span>];<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">else</span> <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span>(<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_X_FORWARDED_FOR&#8217;</span>]))<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_X_FORWARDED_FOR&#8217;</span>];<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">else</span> <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span>(<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_X_FORWARDED&#8217;</span>]))<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_X_FORWARDED&#8217;</span>];<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">else</span> <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span>(<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_FORWARDED_FOR&#8217;</span>]))<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_FORWARDED_FOR&#8217;</span>];<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">else</span> <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span>(<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_FORWARDED&#8217;</span>]))<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;HTTP_FORWARDED&#8217;</span>];<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">else</span> <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span>(<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;REMOTE_ADDR&#8217;</span>]))<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span> = <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$_SERVER</span>[<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;REMOTE_ADDR&#8217;</span>];<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">return</span> <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ipaddress</span>;<br />
}</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// File to store request counts</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$filename</span> = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;ip_counts.txt&#8217;</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Get the client&#8217;s IP address</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$client_ip</span> = <span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">getClientIP</span>();</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Load existing IP counts from the file</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span> = <span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">file_exists</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$filename</span>) ? <span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">json_decode</span>(<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">file_get_contents</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$filename</span>), <span class="hljs-literal" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">true</span>) : [];</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Set the limit for requests</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$request_limit</span> = <span class="hljs-number" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">10</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Check if the IP address has exceeded the limit</span><br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">if</span> (<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span>[<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$client_ip</span>]) &amp;&amp; <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span>[<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$client_ip</span>] &gt;= <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$request_limit</span>) {<br />
<span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Block the IP address</span><br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">echo</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8220;IP address <span class="hljs-subst" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">$client_ip</span> has been blocked due to excessive requests.&#8221;</span>;<br />
<span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Optionally, you can log this event or take further actions (e.g., send an email to the administrator).</span><br />
} <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">else</span> {<br />
<span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Process the request</span><br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">echo</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8220;Request from IP address <span class="hljs-subst" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">$client_ip</span> is allowed.&#8221;</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Update the request count for the IP address</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span>[<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$client_ip</span>] = <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">isset</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span>[<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$client_ip</span>]) ? <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span>[<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$client_ip</span>] + <span class="hljs-number" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">1</span> : <span class="hljs-number" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">1</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Save the updated IP counts to the file</span><br />
<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">file_put_contents</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$filename</span>, <span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">json_encode</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$ip_counts</span>));<br />
}</p>
<p><span class="hljs-meta" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.6);">?&gt;</span></p>
</div>
</div>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">This script checks the number of requests from a specific IP address and blocks it if the limit is exceeded. The request counts are stored in a JSON file (<code style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: 'Söhne Mono', Monaco, 'Andale Mono', 'Ubuntu Mono', monospace !important; font-size: 0.875em; color: var(--tw-prose-code); font-weight: 600;">ip_counts.txt</code> in this example). This is a simple example, and in a real-world scenario, you might want to use a more robust storage solution or database for scalability and reliability.</p>
<p><img loading="lazy" decoding="async" class="wp-image-913 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2023/12/image-28.png" alt="" width="684" height="263" srcset="https://codinghelp.in/wp-content/uploads/2023/12/image-28.png 684w, https://codinghelp.in/wp-content/uploads/2023/12/image-28-300x115.png 300w" sizes="auto, (max-width: 684px) 100vw, 684px" /></p>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Keep in mind that IP-based rate limiting has limitations, and for more advanced scenarios, you might want to consider using a dedicated rate-limiting mechanism or a web application firewall. Additionally, blocking IP addresses should be done cautiously, and it&#8217;s essential to consider potential false positives and the impact on legitimate users.</p>
<p>&nbsp;</p>
<p>Second Methods</p>
<div class="flex flex-grow flex-col max-w-full" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; display: flex; max-width: 100%; flex-grow: 1; flex-direction: column;">
<div class="min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; display: flex; min-height: 20px; flex-direction: column; align-items: flex-start; gap: 0.75rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: break-word;" data-message-author-role="assistant" data-message-id="4bcac0b8-3997-40e2-a6c6-195802d4cafc">
<div class="markdown prose w-full break-words dark:prose-invert light" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: var(--tw-prose-body); max-width: none; --tw-prose-body: #374151; --tw-prose-headings: #111827; --tw-prose-lead: #4b5563; --tw-prose-links: #111827; --tw-prose-bold: #111827; --tw-prose-counters: #6b7280; --tw-prose-bullets: #d1d5db; --tw-prose-hr: #e5e7eb; --tw-prose-quotes: #111827; --tw-prose-quote-borders: #e5e7eb; --tw-prose-captions: #6b7280; --tw-prose-code: #111827; --tw-prose-pre-code: #e5e7eb; --tw-prose-pre-bg: #1f2937; --tw-prose-th-borders: #d1d5db; --tw-prose-td-borders: #e5e7eb; --tw-prose-invert-body: #d1d5db; --tw-prose-invert-headings: #fff; --tw-prose-invert-lead: #9ca3af; --tw-prose-invert-links: #fff; --tw-prose-invert-bold: #fff; --tw-prose-invert-counters: #9ca3af; --tw-prose-invert-bullets: #4b5563; --tw-prose-invert-hr: #374151; --tw-prose-invert-quotes: #f3f4f6; --tw-prose-invert-quote-borders: #374151; --tw-prose-invert-captions: #9ca3af; --tw-prose-invert-code: #fff; --tw-prose-invert-pre-code: #d1d5db; --tw-prose-invert-pre-bg: rgba(0,0,0,.5); --tw-prose-invert-th-borders: #4b5563; --tw-prose-invert-td-borders: #374151; font-size: 1rem; line-height: 1.75; width: 613px; overflow-wrap: break-word;">
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 0px 0px 1.25em;">if you want to implement IP address blocking in PHP after a certain limit is crossed (for example, to prevent too many requests from a single IP), you can use a combination of storage (like a database or a file) and code logic to achieve this. Here&#8217;s a basic example using a file-based approach:</p>
<div class="bg-black rounded-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; border-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(0,0,0,var(--tw-bg-opacity));">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; position: relative; display: flex; align-items: center; justify-content: space-between; border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(52,53,65,var(--tw-bg-opacity)); padding: 0.5rem 1rem; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 0.75rem; line-height: 1rem; --tw-text-opacity: 1; color: rgba(217,217,227,var(--tw-text-opacity));"><span style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">php</span><button class="flex gap-1 items-center" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: inherit; font-family: inherit; font-size: 12px; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-transform: none; appearance: button; background-color: transparent; background-image: none; cursor: pointer; display: flex; align-items: center; gap: 0.25rem;">Copy code</button></div>
<div class="p-4 overflow-y-auto" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; overflow-y: auto; padding: 1rem;">
<p><span style="color: #ffffff;">&lt;?php</span><br />
<span style="color: #ffffff;">// Function to get the client&#8217;s IP address</span><br />
<span style="color: #ffffff;">function getClientIP() {</span><br />
<span style="color: #ffffff;">if (isset($_SERVER[&#8216;HTTP_CLIENT_IP&#8217;])) {</span><br />
<span style="color: #ffffff;">return $_SERVER[&#8216;HTTP_CLIENT_IP&#8217;];</span><br />
<span style="color: #ffffff;">} elseif (isset($_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;])) {</span><br />
<span style="color: #ffffff;">return $_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;];</span><br />
<span style="color: #ffffff;">} else {</span><br />
<span style="color: #ffffff;">return $_SERVER[&#8216;REMOTE_ADDR&#8217;];</span><br />
<span style="color: #ffffff;">}</span><br />
<span style="color: #ffffff;">}</span></p>
<p><span style="color: #ffffff;">// Set a limit for requests</span><br />
<span style="color: #ffffff;">$limit = 5; // Adjust this based on your needs</span></p>
<p><span style="color: #ffffff;">// Get the client&#8217;s IP address</span><br />
<span style="color: #ffffff;">$client_ip = getClientIP();</span></p>
<p><span style="color: #ffffff;">// Check if the IP address is blocked</span><br />
<span style="color: #ffffff;">$blocklistFile = &#8216;blocklist.txt&#8217;;</span><br />
<span style="color: #ffffff;">$blockedIPs = file($blocklistFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);</span></p>
<p><span style="color: #ffffff;">foreach ($blockedIPs as $blockedIP) {</span><br />
<span style="color: #ffffff;">list($ip, $blockTime) = explode(&#8216;|&#8217;, $blockedIP);</span></p>
<p><span style="color: #ffffff;">if ($ip === $client_ip &amp;&amp; (time() &#8211; (int)$blockTime) &lt; 24 * 3600) {</span><br />
<span style="color: #ffffff;">// IP address is still blocked</span><br />
<span style="color: #ffffff;">echo &#8220;IP address $client_ip is blocked. Try again later.&#8221;;</span><br />
<span style="color: #ffffff;">exit;</span><br />
<span style="color: #ffffff;">}</span><br />
<span style="color: #ffffff;">}</span></p>
<p><span style="color: #ffffff;">// Check if the request limit is exceeded</span><br />
<span style="color: #ffffff;">$requestCountFile = &#8216;request_count.txt&#8217;;</span><br />
<span style="color: #ffffff;">$requestCount = (int)file_get_contents($requestCountFile);</span></p>
<p><span style="color: #ffffff;">if ($requestCount &gt;= $limit) {</span><br />
<span style="color: #ffffff;">// Block the IP address and log it</span><br />
<span style="color: #ffffff;">file_put_contents($blocklistFile, &#8220;$client_ip|&#8221; . time() . PHP_EOL, FILE_APPEND);</span><br />
<span style="color: #ffffff;">echo &#8220;IP address $client_ip has been blocked due to excessive requests. Try again later.&#8221;;</span><br />
<span style="color: #ffffff;">exit;</span><br />
<span style="color: #ffffff;">} else {</span><br />
<span style="color: #ffffff;">// Increment the request count</span><br />
<span style="color: #ffffff;">file_put_contents($requestCountFile, ++$requestCount);</span><br />
<span style="color: #ffffff;">}</span></p>
<p><span style="color: #ffffff;">// Your main application logic goes here</span></p>
<p><span style="color: #ffffff;">echo &#8220;Request successfully processed for IP address: $client_ip&#8221;;</span><br />
<span style="color: #ffffff;">?&gt;</span></p>
</div>
</div>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px;">This example uses two files: one to store the count of requests (<code style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: 'Söhne Mono', Monaco, 'Andale Mono', 'Ubuntu Mono', monospace !important; font-size: 0.875em; color: var(--tw-prose-code); font-weight: 600;">request_count.txt</code>) and another to store the blocked IP addresses (<code style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: 'Söhne Mono', Monaco, 'Andale Mono', 'Ubuntu Mono', monospace !important; font-size: 0.875em; color: var(--tw-prose-code); font-weight: 600;">blocklist.txt</code>). You would need to make sure that your web server has write permissions for these files.</p>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px 0px;">Remember that this is a basic example, and in a real-world scenario, you might want to consider using a more robust solution, such as a database, to store and manage blocked IP addresses and request counts. Additionally, consider implementing measures like using CAPTCHA, rate limiting, or other security mechanisms to enhance the security of your application.</p>
</div>
</div>
</div><p>The post <a href="https://codinghelp.in/ip-address-block-after-limit-cross-php/">ip address block after limit cross php</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/ip-address-block-after-limit-cross-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>IP Address Location tracker full source code free download</title>
		<link>https://codinghelp.in/ip-address-location-tracker-full-source-code-free-download/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ip-address-location-tracker-full-source-code-free-download</link>
					<comments>https://codinghelp.in/ip-address-location-tracker-full-source-code-free-download/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Sun, 24 Dec 2023 12:56:05 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<category><![CDATA[WEBSITE TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=908</guid>

					<description><![CDATA[<p>This IP Geolocation PHP module allows user to find the IP geolocation information about an IP address such as country codes, country name, region, district, city, coordinates, ZIP code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, MCC, MNC, mobile brand name, elevation, usage type, address type, [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/ip-address-location-tracker-full-source-code-free-download/">IP Address Location tracker full source code free download</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<div>
<p>This IP Geolocation PHP module allows user to find the IP geolocation information about an IP address such as country codes, country name, region, district, city, coordinates, ZIP code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, MCC, MNC, mobile brand name, elevation, usage type, address type, IAB category and ASN that any IP address or host name originates from. It has been optimized for speed and memory utilization. Developers can use our IP geolocation API to query all IP2Location<img src="https://s.w.org/images/core/emoji/16.0.1/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" /> binary databases for IPv4 and IPv6 address.</p>
<h1><span style="font-size: 18pt;">IP Address Location tracker full source code free download ?</span></h1>
</div>
<p>As of my last knowledge update in January 2023, I don&#8217;t have specific information on the latest libraries or updates that may have been released after that date. For the most current and up-to-date information on IP address geolocation libraries, I recommend checking online resources, official documentation, and community forums.</p>
<p>As of my last update, MaxMind&#8217;s GeoIP2 library was a commonly used option. However, it&#8217;s important to note that services and libraries can evolve, and new options may become available. Always refer to the official documentation of the library you choose for the latest information.</p>
<p>To find the latest and most up-to-date IP geolocation libraries in 2023, you can:</p>
<ol>
<li>Check Online Repositories: Visit platforms like GitHub or PyPI and search for IP geolocation libraries. These platforms often host the latest versions of libraries, and you can find documentation and user reviews.</li>
<li>Visit Official Websites: Go to the official websites of popular IP geolocation providers (such as MaxMind) to see if they have released any updates or new libraries.</li>
<li>Community Forums: Participate in community forums related to geolocation, IP tracking, or relevant programming languages. Communities often share information about the latest tools and libraries.</li>
<li>Developer Documentation: Always refer to the official documentation of any library you are interested in. It should provide details on the latest version, features, and any changes.</li>
</ol>
<p>Keep in mind that the specific needs of your project may influence your choice of library, so it&#8217;s essential to review the documentation and features of each option to find the one that best fits your requirements</p>
<p><img loading="lazy" decoding="async" class="wp-image-909 alignnone size-large" src="https://codinghelp.in/wp-content/uploads/2023/12/image-27.png" alt="" width="640" height="314" srcset="https://codinghelp.in/wp-content/uploads/2023/12/image-27.png 1046w, https://codinghelp.in/wp-content/uploads/2023/12/image-27-300x147.png 300w, https://codinghelp.in/wp-content/uploads/2023/12/image-27-1024x502.png 1024w, https://codinghelp.in/wp-content/uploads/2023/12/image-27-768x377.png 768w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<p>&nbsp;</p>
<p id="the-pasted-async">IP2Location IP Geolocation C library enables the user to find the country, region, city, coordinates, ZIP code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type that any IP address or hostname originates from.</p>
<p>&nbsp;</p>
<pre><code>{
  "ip": "103.175.8.40",
  "city": "Jaipur",
  "region": "Rajasthan",
  "regioncode": "RJ",
  "country": "India",
  "countrycode": "IN",
  "postalcode": "302022",
  "loc": "26.9525,75.7105",
  "time_zone": "Asia/Kolkata",
  "org": "Spiderlink Networks Pvt Ltd",
  "continentcode": "AS",
  "continentname": "Asia",
  "browser": "Chrome",
  "osname": "Windows 10"
}
</code></pre>
<p>&nbsp;</p>
<p>Full Source Code Download Link :  <strong><a href="https://codinghelp.in/wp-content/uploads/2023/12/ipaddressinfo.zip">Click Here</a></strong></p>
<p>&nbsp;</p>
<p>Download IP Info Library</p>
<p>&nbsp;</p>
<p>To install the <code>geoip2/geoip2</code> library using Composer, you can use the following command:</p>
<div class="bg-black rounded-md">
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash">composer require geoip2/geoip2<br />
</code></div>
</div>
<p>Simply run this command in your terminal or command prompt in the root directory of your PHP project, and Composer will automatically download and install the <code>geoip2/geoip2</code> library along with its dependencies.</p>
<p>After running the command, Composer will create or update your <code>composer.json</code> file and install the necessary files in the <code>vendor</code> directory of your project. You can then include the Composer autoloader in your PHP code to use the library:</p>
<div class="bg-black rounded-md">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md"></div>
<div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-php"><span class="hljs-meta">&lt;?php</span></p>
<p><span class="hljs-keyword">require</span> <span class="hljs-string">'vendor/autoload.php'</span>;</p>
<p><span class="hljs-keyword">use</span> <span class="hljs-title">GeoIp2</span>\<span class="hljs-title">Database</span>\<span class="hljs-title">Reader</span>;</p>
<p><span class="hljs-variable">$reader</span> = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Reader</span>(<span class="hljs-string">'path/to/GeoLite2-City.mmdb'</span>);</p>
<p><span class="hljs-variable">$ipAddress</span> = <span class="hljs-string">'8.8.8.8'</span>;</p>
<p><span class="hljs-keyword">try</span> {<br />
    <span class="hljs-variable">$record</span> = <span class="hljs-variable">$reader</span>-&gt;<span class="hljs-title function_ invoke__">city</span>(<span class="hljs-variable">$ipAddress</span>);<br />
    <span class="hljs-keyword">echo</span> <span class="hljs-string">'City: '</span> . <span class="hljs-variable">$record</span>-&gt;city-&gt;name . <span class="hljs-string">"\n"</span>;<br />
    <span class="hljs-keyword">echo</span> <span class="hljs-string">'Country: '</span> . <span class="hljs-variable">$record</span>-&gt;country-&gt;name . <span class="hljs-string">"\n"</span>;<br />
} <span class="hljs-keyword">catch</span> (<span class="hljs-built_in">Exception</span> <span class="hljs-variable">$e</span>) {<br />
    <span class="hljs-keyword">echo</span> <span class="hljs-string">'Error: '</span> . <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getMessage</span>() . <span class="hljs-string">"\n"</span>;<br />
}<br />
</code></div>
</div>
<p>Make sure to replace <code>'path/to/GeoLite2-City.mmdb'</code> with the actual path to your GeoLite2 City database file.</p>
<p>If you haven&#8217;t installed Composer globally, you might need to use <code>php composer.phar require geoip2/geoip2</code> instead. Ensure that the Composer executable (<code>composer</code> or <code>composer.phar</code>) is in your system&#8217;s PATH.</p>
<p>Create <strong>ipinfo.php</strong> files</p>
<pre><code>
&lt;?php require 'geoip2/autoload.php'; use MaxMind\Db\Reader; // Path to the GeoIP2 City database file $databasePath = 'geoip2/GeoLite2-City.mmdb'; if($_REQUEST['ip']){ $clientIp = $_REQUEST['ip']; }else{ // Get client's IP address if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $clientIp = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $clientIp = $_SERVER['REMOTE_ADDR']; } } // Create a reader for the GeoIP2 City database $reader = new Reader($databasePath); $databasePath2 = 'geoip2/GeoLite2-ASN.mmdb'; $reader2 = new Reader($databasePath2); $record2 = $reader2-&gt;get($clientIp);

// Look up the location information for the IP address
$record = $reader-&gt;get($clientIp);

// Display the location information

function get_user_os() {
    $user_agent = $_SERVER['HTTP_USER_AGENT'];

    $os_platform  = "Unknown OS Platform";

    $os_array = array(
        '/windows nt 10/i'      =&gt;  'Windows 10',
        '/windows nt 6.3/i'     =&gt;  'Windows 8.1',
        '/windows nt 6.2/i'     =&gt;  'Windows 8',
        '/windows nt 6.1/i'     =&gt;  'Windows 7',
        '/windows nt 6.0/i'     =&gt;  'Windows Vista',
        '/windows nt 5.2/i'     =&gt;  'Windows Server 2003/XP x64',
        '/windows nt 5.1/i'     =&gt;  'Windows XP',
        '/windows xp/i'         =&gt;  'Windows XP',
        '/windows nt 5.0/i'     =&gt;  'Windows 2000',
        '/windows me/i'         =&gt;  'Windows ME',
        '/win98/i'              =&gt;  'Windows 98',
        '/win95/i'              =&gt;  'Windows 95',
        '/win16/i'              =&gt;  'Windows 3.11',
        '/macintosh|mac os x/i' =&gt;  'Mac OS X',
        '/mac_powerpc/i'        =&gt;  'Mac OS 9',
        '/linux/i'              =&gt;  'Linux',
        '/ubuntu/i'             =&gt;  'Ubuntu',
        '/iphone/i'             =&gt;  'iPhone',
        '/ipod/i'               =&gt;  'iPod',
        '/ipad/i'               =&gt;  'iPad',
        '/android/i'            =&gt;  'Android',
        '/blackberry/i'         =&gt;  'BlackBerry',
        '/webos/i'              =&gt;  'Mobile'
    );

    foreach ($os_array as $regex =&gt; $value) {
        if (preg_match($regex, $user_agent)) {
            $os_platform = $value;
        }
    }

    return $os_platform;
}

$user_os = get_user_os();



function get_user_browser() {
    $user_agent = $_SERVER['HTTP_USER_AGENT'];

    $browser = "Unknown Browser";

    $browser_array = array(
        '/msie/i'      =&gt; 'Internet Explorer',
        '/firefox/i'   =&gt; 'Firefox',
        '/safari/i'    =&gt; 'Safari',
        '/chrome/i'    =&gt; 'Chrome',
        '/edge/i'      =&gt; 'Edge',
        '/opera/i'     =&gt; 'Opera',
        '/netscape/i'  =&gt; 'Netscape',
        '/maxthon/i'   =&gt; 'Maxthon',
        '/konqueror/i' =&gt; 'Konqueror',
        '/mobile/i'    =&gt; 'Handheld Browser'
    );

    foreach ($browser_array as $regex =&gt; $value) {
        if (preg_match($regex, $user_agent)) {
            $browser = $value;
        }
    }

    return $browser;
}

$user_browser = get_user_browser();

    $url = "https://ipinfo.io/$clientIp/json";
    $response = file_get_contents($url);
    $data = json_decode($response, true);
    
 if($record['city']['names']['en']==false){
     $ipinfo = '{
  "ip": "'.$clientIp.'",
  "city": "'.$data['city'].'",
  "region": "'.$data['region'].'",
  "countrycode": "'.$data['country'].'",
  "postalcode": "'.$data['postal'].'",
  "loc": "'.$data['loc'].'",
  "time_zone": "'.$data['timezone'].'",
  "org": "'.$data['org'].'",
  "browser": "'.$user_browser.'",
  "osname": "'.$user_os.'"
}';
 }else{   

$ipinfo = '{
  "ip": "'.$clientIp.'",
  "city": "'.$record['city']['names']['en'].'",
  "region": "'.$record['subdivisions'][0]['names']['en'].'",
  "regioncode": "'.$record['subdivisions'][0]['iso_code'].'",
  "country": "'.$record['country']['names']['en'].'",
  "countrycode": "'.$record['country']['iso_code'].'",
  "postalcode": "'.$record['postal']['code'].'",
  "loc": "'.$record['location']['latitude'].','. $record['location']['longitude'].'",
  "time_zone": "'.$record['location']['time_zone'].'",
  "org": "'.$record2['autonomous_system_organization'].'",
  "continentcode": "'.$record['continent']['code'].'",
  "continentname": "'.$record['continent']['names']['en'].'",
  "browser": "'.$user_browser.'",
  "osname": "'.$user_os.'"
}';
}
print_r($ipinfo);

// Close the GeoIP2 reader
$reader-&gt;close();

</code></pre>
<p>&nbsp;</p><p>The post <a href="https://codinghelp.in/ip-address-location-tracker-full-source-code-free-download/">IP Address Location tracker full source code free download</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/ip-address-location-tracker-full-source-code-free-download/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PHPMailer Source Code Download With File Upload</title>
		<link>https://codinghelp.in/phpmailer-source-code-download-with-file-upload/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=phpmailer-source-code-download-with-file-upload</link>
					<comments>https://codinghelp.in/phpmailer-source-code-download-with-file-upload/#respond</comments>
		
		<dc:creator><![CDATA[Coding Help]]></dc:creator>
		<pubDate>Sat, 02 Dec 2023 15:21:24 +0000</pubDate>
				<category><![CDATA[PHP TUTORIAL]]></category>
		<guid isPermaLink="false">https://codinghelp.in/?p=842</guid>

					<description><![CDATA[<p>Providing or assisting in obtaining source code that is not freely available and shared by its creators would be against ethical guidelines. Additionally, sharing or obtaining proprietary code without proper authorization may violate copyrights and licensing agreements. If you&#8217;re looking for PHPMailer, it is an open-source project available on GitHub, and you can download it [&#8230;]</p>
<p>The post <a href="https://codinghelp.in/phpmailer-source-code-download-with-file-upload/">PHPMailer Source Code Download With File Upload</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></description>
										<content:encoded><![CDATA[<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 0px 0px 1.25em; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Providing or assisting in obtaining source code that is not freely available and shared by its creators would be against ethical guidelines. Additionally, sharing or obtaining proprietary code without proper authorization may violate copyrights and licensing agreements.</p>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">If you&#8217;re looking for PHPMailer, it is an open-source project available on GitHub, and you can download it from there: <a style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(41,100,170,var(--tw-text-opacity)); text-decoration: none; font-weight: 400; --tw-text-opacity: 1;" href="https://github.com/PHPMailer/PHPMailer" target="_new" rel="noopener">PHPMailer GitHub Repository</a></p>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">If you have specific questions about using PHPMailer or need help with a particular aspect of your code, feel free to ask, and I&#8217;ll do my best to assist you within ethical boundaries.</p>
<p>&nbsp;</p>
<h2>PHPMailer Source Code Download With File Upload ?</h2>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 0px 0px 1.25em; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">If you want to use PHPMailer to send an email with base64-encoded content (such as an image), you can certainly achieve that. Below is an example demonstrating how to use PHPMailer to send an email with a base64-encoded image attachment.</p>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Make sure you have PHPMailer installed. You can install it using Composer:</p>
<div class="bg-black rounded-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; border-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(0,0,0,var(--tw-bg-opacity));">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; position: relative; display: flex; align-items: center; justify-content: space-between; border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(52,53,65,var(--tw-bg-opacity)); padding: 0.5rem 1rem; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 0.75rem; line-height: 1rem; --tw-text-opacity: 1; color: rgba(217,217,227,var(--tw-text-opacity));"><span style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">bash</span><button class="flex gap-1 items-center" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: inherit; font-family: inherit; font-size: 12px; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-transform: none; appearance: button; background-color: transparent; background-image: none; cursor: pointer; display: flex; align-items: center; gap: 0.25rem;">Copy code</button></div>
<div class="p-4 overflow-y-auto" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-bash" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: inherit; font-size: inherit; color: #ffffff; font-weight: inherit; background: none; border-radius: 0.3em; line-height: 1.5; padding: 0.1em; white-space: normal; overflow-wrap: normal; hyphens: none; tab-size: 4; text-align: left; word-break: normal; word-spacing: normal;">composer require phpmailer/phpmailer<br />
</code></div>
</div>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Now, here&#8217;s a simple example:</p>
<div class="bg-black rounded-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; border-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(0,0,0,var(--tw-bg-opacity));">
<div class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; position: relative; display: flex; align-items: center; justify-content: space-between; border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; --tw-bg-opacity: 1; background-color: rgba(52,53,65,var(--tw-bg-opacity)); padding: 0.5rem 1rem; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 0.75rem; line-height: 1rem; --tw-text-opacity: 1; color: rgba(217,217,227,var(--tw-text-opacity));"><span style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">php</span><button class="flex gap-1 items-center" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: inherit; font-family: inherit; font-size: 12px; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-transform: none; appearance: button; background-color: transparent; background-image: none; cursor: pointer; display: flex; align-items: center; gap: 0.25rem;">Copy code</button></div>
<div class="p-4 overflow-y-auto" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; overflow-y: auto; padding: 1rem;">
<p><code class="!whitespace-pre hljs language-php" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: inherit; font-size: inherit; color: #ffffff; font-weight: inherit; background: none; border-radius: 0.3em; line-height: 1.5; padding: 0.1em; white-space: normal; overflow-wrap: normal; hyphens: none; tab-size: 4; text-align: left; word-break: normal; word-spacing: normal;"><span class="hljs-meta" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.6);">&lt;?php</span></code></p>
<p><span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">require</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;vendor/autoload.php&#8217;</span>;</p>
<p><span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">use</span> <span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">PHPMailer</span>\<span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">PHPMailer</span>\<span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">PHPMailer</span>;<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">use</span> <span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">PHPMailer</span>\<span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">PHPMailer</span>\<span class="hljs-title" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">Exception</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Create a new PHPMailer instance</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span> = <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">new</span> <span class="hljs-title class_" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">PHPMailer</span>(<span class="hljs-literal" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">true</span>);</p>
<p><span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">try</span> {<br />
<span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Server settings</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">isSMTP</span>();<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span style="color: #ff0000;">Host</span> = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;smtp.gmail.com&#8217;</span>;<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span style="color: #ff0000;">SMTPAuth</span> = <span class="hljs-literal" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">true</span>;<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span style="color: #ff0000;">Username</span> = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;your_username@example.com&#8217;</span>;<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span style="color: #ff0000;">Password</span> = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;your_password&#8217;</span>;<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span style="color: #ff0000;">SMTPSecure</span> = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;ssl&#8217;</span>;<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span style="color: #ff0000;">Port</span> = <span style="color: #339966;">465</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Sender and recipient</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">setFrom</span>(<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;your_username@example.com&#8217;</span>, <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;Your Name&#8217;</span>);<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">addAddress</span>(<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;recipient@example.com&#8217;</span>, <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;Recipient Name&#8217;</span>);</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Email subject and body</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;Subject = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;Subject of the email&#8217;</span>;<br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;Body = <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;Body of the email&#8217;</span>;</p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Base64-encoded image attachment</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$base64Image</span> = <span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">file_get_contents</span>(<span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;path/to/your/base64_encoded_image.txt&#8217;</span>); <span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Replace with your actual base64 file</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">addStringAttachment</span>(<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">base64_decode</span>(<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$base64Image</span>), <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;image.jpg&#8217;</span>, <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;base64&#8217;</span>, <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;image/jpeg&#8217;</span>);</p>
<p><span style="color: #339966;"><strong><span style="color: #ff0000;">$mail<span style="color: #333333;">-&gt;</span>addStringAttachment(file_get_contents</span>($_FILES[&#8216;demoform&#8217;][&#8216;tmp_name&#8217;]), $_FILES[&#8216;demoform&#8217;][&#8216;name&#8217;], &#8216;base64&#8217;, $_FILES[&#8216;demoform&#8217;][&#8216;type&#8217;]); </strong></span></p>
<p><span class="hljs-comment" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.5);">// Send the email</span><br />
<span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$mail</span>-&gt;<span class="hljs-title function_ invoke__" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #f22c3d;">send</span>();</p>
<p><span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">echo</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8216;Email sent successfully&#8217;</span>;<br />
} <span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">catch</span> (<span class="hljs-built_in" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #e9950c;">Exception</span> <span class="hljs-variable" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #df3079;">$e</span>) {<br />
<span class="hljs-keyword" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #2e95d3;">echo</span> <span class="hljs-string" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: #00a67d;">&#8220;Message could not be sent. Mailer Error: <span class="hljs-subst" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent;">{$mail-&gt;ErrorInfo}</span>&#8220;</span>;<br />
}<br />
<span class="hljs-meta" style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; color: rgba(255, 255, 255, 0.6);">?&gt;</span></p>
</div>
</div>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Replace the placeholders in the script with your actual email server details, sender, recipient, subject, and body. Also, replace <code style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; font-family: 'Söhne Mono', Monaco, 'Andale Mono', 'Ubuntu Mono', monospace !important; font-size: 0.875em; color: var(--tw-prose-code); font-weight: 600;">'path/to/your/base64_encoded_image.txt'</code> with the path to your actual base64-encoded image file.</p>
<p style="border: 0px solid #d9d9e3; box-sizing: border-box; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(69,89,164,.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; margin: 1.25em 0px 0px; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre-wrap; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Keep in mind that base64 encoding is often used for small images or binary data. If your image is too large, you may run into issues with email size limits. In such cases, consider using links to hosted images or attachments with standard encoding.</p><p>The post <a href="https://codinghelp.in/phpmailer-source-code-download-with-file-upload/">PHPMailer Source Code Download With File Upload</a> first appeared on <a href="https://codinghelp.in">Coding Help - Codinghelp.in</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://codinghelp.in/phpmailer-source-code-download-with-file-upload/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
