<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Eliminare utenti dal database con Php.]]></title><description><![CDATA[<p dir="auto">Salve ragazzi!</p>
<p dir="auto">E' sabato e non c'è giorno migliore per aprire la seguente discussione <img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/android/1f61b.png?v=4as8rolt52f" class="not-responsive emoji emoji-android emoji--stuck_out_tongue" title=":P" alt="😛" /></p>
<p dir="auto">Parto postando i file interessati nel problema:</p>
<p dir="auto">Preannuncio che parliamo di un sito in php con cui gestisco gli utenti.</p>
<p dir="auto">nella cartella "/controlli" ho il file impostazioni_profilo.php</p>
<p dir="auto">[PHP]&lt;?php</p>
<pre><code>if( !$this-&gt;network-&gt;id ) {
	$this-&gt;redirect('home');
}
if( !$this-&gt;user-&gt;is_logged ) {
	$this-&gt;redirect('signin');
}

$this-&gt;load_langfile('inside/global.php');
$this-&gt;load_langfile('inside/settings.php');

$D-&gt;page_title	= $this-&gt;lang('settings_profile_pagetitle', array('#SITE_TITLE#'=&gt;$C-&gt;SITE_TITLE));

$D-&gt;menu_bdate_d	= array();
$D-&gt;menu_bdate_m	= array();
$D-&gt;menu_bdate_y	= array();
if( $this-&gt;user-&gt;info-&gt;birthdate == '0000-00-00' ) {
	$D-&gt;menu_bdate_d[0]	= '';
	$D-&gt;menu_bdate_m[0]	= '';
	$D-&gt;menu_bdate_y[0]	= '';
}
for($i=1; $i&lt;=31; $i++) {
	$D-&gt;menu_bdate_d*	= $i;
}
for($i=1; $i&lt;=12; $i++) {
	$D-&gt;menu_bdate_m*	= strftime('%B', mktime(0,0,1,$i,1,2009));
}
for($i=intval(date('Y')); $i&gt;=1900; $i--) {
	$D-&gt;menu_bdate_y*	= $i;
}

$D-&gt;submit	= FALSE;
$D-&gt;error	= FALSE;
$D-&gt;errmsg	= '';

$D-&gt;name		= $this-&gt;user-&gt;info-&gt;fullname;
$D-&gt;location	= $this-&gt;user-&gt;info-&gt;location;
$D-&gt;gender		= $this-&gt;user-&gt;info-&gt;gender;
$D-&gt;aboutme		= $this-&gt;user-&gt;info-&gt;about_me;
$D-&gt;tags		= implode(', ', $this-&gt;user-&gt;info-&gt;tags);
$D-&gt;bdate_d		= 0;
$D-&gt;bdate_m		= 0;
$D-&gt;bdate_y		= 0;
if( $this-&gt;user-&gt;info-&gt;birthdate != '0000-00-00' ) {
	$D-&gt;bdate_d		= intval(substr($this-&gt;user-&gt;info-&gt;birthdate,8,2));
	$D-&gt;bdate_m		= intval(substr($this-&gt;user-&gt;info-&gt;birthdate,5,2));
	$D-&gt;bdate_y		= intval(substr($this-&gt;user-&gt;info-&gt;birthdate,0,4));
}

$u	= $this-&gt;user-&gt;info;

$tmphash	= md5($u-&gt;fullname.$u-&gt;location.$u-&gt;birthdate.$u-&gt;gender.$u-&gt;about_me.serialize($u-&gt;tags));

if( isset($_POST['sbm']) ) {
	$D-&gt;submit	= TRUE;
	$D-&gt;name		= trim($_POST['name']);
	$D-&gt;location	= trim($_POST['location']);
	$D-&gt;gender		= isset($_POST['gender']) ? trim($_POST['gender']) : '';
	$D-&gt;aboutme		= trim($_POST['aboutme']);
	$D-&gt;tags		= trim($_POST['tags']);
	$D-&gt;bdate_d		= intval($_POST['bdate_d']);
	$D-&gt;bdate_m		= intval($_POST['bdate_m']);
	$D-&gt;bdate_y		= intval($_POST['bdate_y']);
	if( $D-&gt;gender!='m' &amp;&amp; $D-&gt;gender!='f' ) {
		$D-&gt;gender	= '';
	}
	if( !isset($D-&gt;menu_bdate_m[$D-&gt;bdate_m]) || !isset($D-&gt;menu_bdate_d[$D-&gt;bdate_d]) || !isset($D-&gt;menu_bdate_y[$D-&gt;bdate_y]) ) {
		$D-&gt;bdate_m	= 0;
		$D-&gt;bdate_d	= 0;
		$D-&gt;bdate_y	= 0;
	}
	if( $D-&gt;bdate_d==0 || $D-&gt;bdate_m==0 || $D-&gt;bdate_y==0 ) {
		$D-&gt;bdate_m	= 0;
		$D-&gt;bdate_d	= 0;
		$D-&gt;bdate_y	= 0;
		$birthdate	= '0000-00-00';
	}
	else {
		$birthdate	= $D-&gt;bdate_y.'-'.str_pad($D-&gt;bdate_m,2,0,STR_PAD_LEFT).'-'.str_pad($D-&gt;bdate_d,2,0,STR_PAD_LEFT);
	}
	$D-&gt;tags	= str_replace(array("\n","\r"), ',', $D-&gt;tags);
	$D-&gt;tags	= preg_replace('/\,+/ius', ',', $D-&gt;tags);
	$D-&gt;tags	= explode(',', $D-&gt;tags);
	foreach($D-&gt;tags as $k=&gt;$v) {
		$v	= trim($v);
		if( FALSE == preg_match('/^[a-z&amp;#1072;-&amp;#1103;0-9\-\_\.\s\+]{2,}$/iu', $v) ) {
			unset($D-&gt;tags[$k]);
			continue;
		}
		$D-&gt;tags[$k]	= $v;
	}
	$D-&gt;tags	= implode(', ', $D-&gt;tags);
	
	$db2-&gt;query('UPDATE users SET fullname="'.$db2-&gt;e($D-&gt;name).'", about_me="'.$db2-&gt;e($D-&gt;aboutme).'", tags="'.$db2-&gt;e($D-&gt;tags).'", gender="'.$db2-&gt;e($D-&gt;gender).'", birthdate="'.$db2-&gt;e($birthdate).'", location="'.$db2-&gt;e($D-&gt;location).'" WHERE id="'.$this-&gt;user-&gt;id.'" LIMIT 1');
	
	$this-&gt;user-&gt;sess['LOGGED_USER']	= $this-&gt;network-&gt;get_user_by_id($this-&gt;user-&gt;id, TRUE);
	$this-&gt;user-&gt;info	= &amp; $this-&gt;user-&gt;sess['LOGGED_USER'];
	
	$u	= $this-&gt;user-&gt;info;
	$tmphash2	= md5($u-&gt;fullname.$u-&gt;location.$u-&gt;birthdate.$u-&gt;gender.$u-&gt;about_me.serialize($u-&gt;tags));
	if( $tmphash != $tmphash2 ) {
		$n	= intval( $this-&gt;network-&gt;get_user_notif_rules($this-&gt;user-&gt;id)-&gt;ntf_them_if_i_edt_profl );
		if( $n == 1 ) {
			$this-&gt;load_langfile('inside/notifications.php');
			$this-&gt;load_langfile('email/notifications.php');
			$followers	= array_keys($this-&gt;network-&gt;get_user_follows($this-&gt;user-&gt;id)-&gt;followers);
			foreach($followers as $uid) {
				$send_post	= FALSE;
				$send_mail	= FALSE;
				$n	= intval( $this-&gt;network-&gt;get_user_notif_rules($uid)-&gt;ntf_me_if_u_edt_profl );
				if( $n == 2 ) { $send_post = TRUE; } elseif( $n == 3 ) { $send_mail = TRUE; } elseif( $n == 1 ) { $send_post = TRUE; $send_mail = TRUE; }
				if( $send_post ) {
					$lng	= array('#USER#'=&gt;'&lt;a href="'.$C-&gt;SITE_URL.$this-&gt;user-&gt;info-&gt;username.'" title="'.htmlspecialchars($this-&gt;user-&gt;info-&gt;fullname).'"&gt;&lt;span class="mpost_mentioned"&gt;@&lt;/span&gt;'.$this-&gt;user-&gt;info-&gt;username.'&lt;/a&gt;');
					$this-&gt;network-&gt;send_notification_post($uid, 0, 'msg_ntf_me_if_u_edt_profl', $lng, 'replace');
				}
				if( $send_mail ) {
					$lng_txt	= array('#SITE_TITLE#'=&gt;$C-&gt;SITE_TITLE, '#USER#'=&gt;'@'.$this-&gt;user-&gt;info-&gt;username, '#NAME#'=&gt;$this-&gt;user-&gt;info-&gt;fullname, '#A0#'=&gt;$C-&gt;SITE_URL.$this-&gt;user-&gt;info-&gt;username);
					$lng_htm	= array('#SITE_TITLE#'=&gt;$C-&gt;SITE_TITLE, '#USER#'=&gt;'&lt;a href="'.$C-&gt;SITE_URL.$this-&gt;user-&gt;info-&gt;username.'" title="'.htmlspecialchars($this-&gt;user-&gt;info-&gt;fullname).'" target="_blank"&gt;@'.$this-&gt;user-&gt;info-&gt;username.'&lt;/a&gt;', '#NAME#'=&gt;$this-&gt;user-&gt;info-&gt;fullname, '#A0#'=&gt;'');
					$subject		= $this-&gt;lang('emlsubj_ntf_me_if_u_edt_profl', $lng_txt);
					$message_txt	= $this-&gt;lang('emltxt_ntf_me_if_u_edt_profl', $lng_txt);
					$message_htm	= $this-&gt;lang('emlhtml_ntf_me_if_u_edt_profl', $lng_htm);
					$this-&gt;network-&gt;send_notification_email($uid, 'u_edt_profl', $subject, $message_txt, $message_htm);
				}
			}
		}
	}
}

$this-&gt;load_template('impostazioni_profilo.php');
</code></pre>
<p dir="auto">?&gt;[/PHP]</p>
<p dir="auto">Il file Template impostazioni_profilo.php contiene invece:</p>
<p dir="auto">[PHP]&lt;?php</p>
<pre><code>$this-&gt;load_template('header.php');
</code></pre>
<p dir="auto">?&gt;<br />
&lt;div id="settings"&gt;<br />
&lt;div id="settings_left"&gt;				<br />
&lt;div class="ttl" style="margin-right:12px;"&gt;&lt;div class="ttl2"&gt;&lt;h3&gt;&lt;?= $this-&gt;lang('settings_menu_title') ?&gt;&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;<br />
&lt;div class="sidenav"&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/profile" class="onsidenav"&gt;&lt;?= $this-&gt;lang('settings_menu_profile') ?&gt;&lt;/a&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/contacts"&gt;&lt;?= $this-&gt;lang('settings_menu_contacts') ?&gt;&lt;/a&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/avatar"&gt;&lt;?= $this-&gt;lang('settings_menu_avatar') ?&gt;&lt;/a&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/esporta"&gt;Esporta Profilo&lt;/a&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/password"&gt;&lt;?= $this-&gt;lang('settings_menu_password') ?&gt;&lt;/a&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/system"&gt;&lt;?= $this-&gt;lang('settings_menu_system') ?&gt;&lt;/a&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/notifications"&gt;&lt;?= $this-&gt;lang('settings_menu_notif') ?&gt;&lt;/a&gt;<br />
&lt;?php if( function_exists('curl_init') ) { ?&gt;<br />
&lt;a href="&lt;?= $C-&gt;SITE_URL ?&gt;settings/rssfeeds"&gt;&lt;?= $this-&gt;lang('settings_menu_rssfeeds') ?&gt;&lt;/a&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;div id="settings_right"&gt;<br />
&lt;?php if($D-&gt;submit) { ?&gt;<br />
&lt;?= okbox($this-&gt;lang('st_profile_ok'), $this-&gt;lang('st_profile_okmsg')) ?&gt;<br />
&lt;?php } ?&gt;<br />
&lt;div class="ttl"&gt;&lt;div class="ttl2"&gt;<br />
&lt;h3&gt;&lt;?= $this-&gt;lang('settings_profile_ttl2') ?&gt;&lt;/h3&gt;<br />
&lt;a class="ttlink" href="&lt;?= $C-&gt;SITE_URL ?&gt;&lt;?= $this-&gt;user-&gt;info-&gt;username ?&gt;/tab:info"&gt;&lt;?= $this-&gt;lang('settings_viewprofile_link') ?&gt;&lt;/a&gt;<br />
&lt;/div&gt;&lt;/div&gt;<br />
&lt;form method="post" action=""&gt;<br />
&lt;table id="setform" cellspacing="5"&gt;<br />
&lt;tr&gt;<br />
&lt;td class="setparam"&gt;&lt;?= $this-&gt;lang('st_profile_name') ?&gt;&lt;/td&gt;<br />
&lt;td&gt;&lt;input type="text" name="name" value="&lt;?= htmlspecialchars($D-&gt;name) ?&gt;" class="setinp" maxlength="255" /&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td class="setparam"&gt;&lt;?= $this-&gt;lang('st_profile_location') ?&gt;&lt;/td&gt;<br />
&lt;td&gt;&lt;input type="text" name="location" value="&lt;?= htmlspecialchars($D-&gt;location) ?&gt;" class="setinp" maxlength="255" /&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td class="setparam"&gt;&lt;?= $this-&gt;lang('st_profile_birthdate') ?&gt;&lt;/td&gt;<br />
&lt;td&gt;<br />
&lt;select name="bdate_d" class="setselect" style="width:55px;"&gt;<br />
&lt;?php foreach($D-&gt;menu_bdate_d as $k=&gt;$v) { ?&gt;<br />
&lt;option value="&lt;?= $k ?&gt;"&lt;?= $k==$D-&gt;bdate_d?' selected="selected"':'' ?&gt;&gt;&lt;?= $v ?&gt;&lt;/option&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/select&gt;<br />
&lt;select name="bdate_m" class="setselect" style="width:130px;"&gt;<br />
&lt;?php foreach($D-&gt;menu_bdate_m as $k=&gt;$v) { ?&gt;<br />
&lt;option value="&lt;?= $k ?&gt;"&lt;?= $k==$D-&gt;bdate_m?' selected="selected"':'' ?&gt;&gt;&lt;?= $v ?&gt;&lt;/option&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/select&gt;<br />
&lt;select name="bdate_y" class="setselect" style="width:70px;"&gt;<br />
&lt;?php foreach($D-&gt;menu_bdate_y as $k=&gt;$v) { ?&gt;<br />
&lt;option value="&lt;?= $k ?&gt;"&lt;?= $k==$D-&gt;bdate_y?' selected="selected"':'' ?&gt;&gt;&lt;?= $v ?&gt;&lt;/option&gt;<br />
&lt;?php } ?&gt;<br />
&lt;/select&gt;<br />
&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td class="setparam" valign="top"&gt;&lt;?= $this-&gt;lang('st_profile_gender') ?&gt;&lt;/td&gt;<br />
&lt;td&gt;<br />
&lt;label&gt;&lt;input type="radio" name="gender" value="m" &lt;?= $D-&gt;gender=='m'?'checked="checked"':'' ?&gt; /&gt; &lt;span&gt;&lt;?= $this-&gt;lang('st_profile_gender_m') ?&gt;&lt;/span&gt;&lt;/label&gt;<br />
&lt;label&gt;&lt;input type="radio" name="gender" value="f" &lt;?= $D-&gt;gender=='f'?'checked="checked"':'' ?&gt; /&gt; &lt;span&gt;&lt;?= $this-&gt;lang('st_profile_gender_f') ?&gt;&lt;/span&gt;&lt;/label&gt;<br />
&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td class="setparam" valign="top"&gt;&lt;?= $this-&gt;lang('st_profile_aboutme') ?&gt;&lt;/td&gt;<br />
&lt;td&gt;&lt;textarea name="aboutme" class="setinp" style="height:90px;"&gt;&lt;?= htmlspecialchars($D-&gt;aboutme) ?&gt;&lt;/textarea&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td class="setparam" valign="top"&gt;&lt;?= $this-&gt;lang('st_profile_tags') ?&gt;&lt;/td&gt;<br />
&lt;td&gt;&lt;textarea name="tags" class="setinp"&gt;&lt;?= htmlspecialchars($D-&gt;tags) ?&gt;&lt;/textarea&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td&gt;&lt;/td&gt;<br />
&lt;td&gt;&lt;input type="submit" name="sbm" value="&lt;?= $this-&gt;lang('st_profile_savebtn') ?&gt;" style="padding:4px; font-weight:bold;"/&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/form&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;?php</p>
<pre><code>$this-&gt;load_template('footer.php');
</code></pre>
<p dir="auto">?&gt;[/PHP]</p>
<p dir="auto">e nella root principale ho il file di configurazione config.php che contiene:</p>
<p dir="auto">[PHP]// MySQL SETTINGS<br />
//<br />
$C-&gt;DB_HOST	= 'host';<br />
$C-&gt;DB_USER	= 'sqluser';<br />
$C-&gt;DB_PASS	= 'pass';<br />
$C-&gt;DB_NAME	= 'nome db';</p>
<p dir="auto">e altro... [/PHP]</p>
<p dir="auto">Come è facile intuire, il database del mio sito contiene una tabella chiamata <strong>users</strong> in cui ci sono tutti i dati degli utenti (username, email, password, tel., link facebook etc.)</p>
<p dir="auto">Mi sapete dire come fare per creare un link - nella pagina impostazioni - tramite cui l'utente possa eliminare il proprio account? Cerco in rete da giorni ma non ho trovato nulla di buono, non mi funzionano i codici che ho provato.</p>
<p dir="auto">Chi sa aiutarmi?</p>
]]></description><link>https://connect.gt/topic/109318/eliminare-utenti-dal-database-con-php</link><generator>RSS for Node</generator><lastBuildDate>Thu, 14 May 2026 08:22:48 GMT</lastBuildDate><atom:link href="https://connect.gt/topic/109318.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Feb 2010 13:49:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Eliminare utenti dal database con Php. on Tue, 23 Feb 2010 09:48:16 GMT]]></title><description><![CDATA[<p dir="auto">Una prima idea(alquanto brutale <img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/customizations/1881713c-5c09-4986-bf15-fa308ef84b2e-smilegt.gif?v=4as8rolt52f" class="not-responsive emoji emoji-customizations emoji--smile5" title=":smile5:" alt=":smile5:" />) potrebbe essere modificare il Template impostazioni_profilo.php aggiungendo al fianco del bottone per il submit un link del tipo<br />
[HTML]&lt;a href="cancella.php?id=&lt;id_utente&gt;"&gt;Cancella Account&lt;/a&gt;[/HTML]<br />
inserendo al posto di &lt;id_utente&gt; il relativo valore, dopo di che nella pagina cancella.php ricavi l'id dell'utente da cancellare con<br />
[PHP]$id = $_REQUEST['id'];[/PHP]<br />
e crei la query per la cancellazione..</p>
<p dir="auto">Spero di essere stato chiaro <img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/customizations/6551d194-c64c-4e45-9dcf-2a85dc41b3fb-sun.gif?v=4as8rolt52f" class="not-responsive emoji emoji-customizations emoji--sun" title=":sun:" alt=":sun:" /></p>
]]></description><link>https://connect.gt/post/854129</link><guid isPermaLink="true">https://connect.gt/post/854129</guid><dc:creator><![CDATA[sirfabio]]></dc:creator><pubDate>Tue, 23 Feb 2010 09:48:16 GMT</pubDate></item><item><title><![CDATA[Reply to Eliminare utenti dal database con Php. on Mon, 22 Feb 2010 15:40:30 GMT]]></title><description><![CDATA[<p dir="auto">si e sto impazzendo...</p>
]]></description><link>https://connect.gt/post/854119</link><guid isPermaLink="true">https://connect.gt/post/854119</guid><dc:creator><![CDATA[lasslo]]></dc:creator><pubDate>Mon, 22 Feb 2010 15:40:30 GMT</pubDate></item><item><title><![CDATA[Reply to Eliminare utenti dal database con Php. on Mon, 22 Feb 2010 15:29:11 GMT]]></title><description><![CDATA[<p dir="auto">scusa la domanda...quindi vuoi semplicemente cancellare un utente dalla tabella users?</p>
]]></description><link>https://connect.gt/post/854128</link><guid isPermaLink="true">https://connect.gt/post/854128</guid><dc:creator><![CDATA[sirfabio]]></dc:creator><pubDate>Mon, 22 Feb 2010 15:29:11 GMT</pubDate></item></channel></rss>